[svlug] [perl] question

Lutz Birkhahn lutz.birkhahn at gmx.de
Sun Jan 27 13:40:02 PST 2002

Bill Schoolcraft wrote:
> In using the special literal __FILE__ I'm trying to print the name
> of the file in my cgi-scripts output, it does so "BUT" give me the
> absolute path, I'm just looking for the filename. Can any tell me
> what to change.?

  use File::Basename;

  print "The name of the perl script is ",basename(__FILE__),".\n";

$0 also contains the name of the script. Seems to me "more normal" than
__FILE__, especially after reading "man perldata" about special literals:
"they may be used only as separate tokens; they will not be interpolated
into strings...".


Lutz Birkhahn

More information about the svlug mailing list