让我告诉您三个特殊的文字__FILE__,__LINE__和__PACKAGE__表示程序中该点的当前文件名,行号和程序包名称。
它们只能用作单独的标记,而不会内插到字符串中。检查以下示例-
#!/usr/bin/perl print "File name ". __FILE__ . "\n"; print "Line Number " . __LINE__ ."\n"; print "Package " . __PACKAGE__ ."\n"; # they can not be interpolated print "__FILE__ __LINE__ __PACKAGE__\n";
输出结果
这将产生以下结果-
File name hello.pl Line Number 4 Package main __FILE__ __LINE__ __PACKAGE__