perl脚本的文件句柄__FILE__的输出是什么?
__FILE__输出的是文件名还是敲的命令?我最开始建立的一个简单脚本命名为1.pl,放在桌面的,在终端下进入/root/Desktop/文件夹下,由于不能直接输入文件名...
__FILE__输出的是文件名还是敲的命令?我最开始建立的一个简单脚本命名为1.pl,放在桌面的,在终端下进入/root/Desktop/ 文件夹下,由于不能直接输入文件名1.pl运行,所以我用了./1.pl 结果文件名显示为了./1.pl。将命令改为../root/Desktop/1.pl后 显示的是../root/Desktop/1.pl。这样将绝对路径输出从安全上讲是非常恶劣的。或许是否可以从其他程序(脚本或是网页)运行脚本不会出现这样的情况?
大哥,请讲中文好不好? 展开
大哥,请讲中文好不好? 展开
1个回答
展开全部
__FILE__ & __LINE__
These are two special markers that return, respectively, the name of the file Perl is currently executing, and the Line number where it resides. These can be used in your own debugging statements, to remind yourself where your outputs were in the source code:
print "On line " . __LINE__ . " of file " . __FILE__;
These are two special markers that return, respectively, the name of the file Perl is currently executing, and the Line number where it resides. These can be used in your own debugging statements, to remind yourself where your outputs were in the source code:
print "On line " . __LINE__ . " of file " . __FILE__;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询