in reply to Searching for an alternative to $0


See __PACKAGE__ in perldata.
#!/usr/bin/perl -wl print __PACKAGE__; package My::Package; print __PACKAGE__; __END__ Prints: main My::Package

Update: As per the comment below, if you want the filename and not the package name then you should use __FILE__, also in perldata.

--
John.

Replies are listed 'Best First'.
Re: Searching for an alternative to $0
by Abigail-II (Bishop) on May 19, 2004 at 08:46 UTC
    Considering the OP is asking for a filename, and your proposed solution using __PACKAGE__ gives two different results for the same file, it's obvious your solution can't be correct.

    Abigail