【发布时间】:2010-11-01 17:35:13
【问题描述】:
我想在 Perl 脚本中获取当前文件名和行号。我该怎么做?
例如在文件中调用test.pl:
my $foo = 'bar';
print 'Hello, World!';
print functionForFilename() . ':' . functionForLineNo();
它会输出:
Hello, World!
test.pl:3
【问题讨论】:
-
对于当前的输入文件(不是这里的Perl 源文件) ,请参阅How to get the filename of the current file in a Perl one-liner。
标签: perl