svlug-perl_file_basename

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



From: Lutz Birkhahn <lutz.birkhahn@gmx.de>
To: Bill Schoolcraft <bill@wiliweld.com>,
Subject: Re: [svlug] [perl] question
Date: Sun, 27 Jan 2002 13:34:25 -0800

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...".

===

the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu