c has asked for the wisdom of the Perl Monks concerning the following question:

I know that $0 refers to the name of the current perl script being executed. However when I run this, it returns a full path. Parsing out just the name should not be that large of a deal. Maybe something like:

$0 = (split(/\//, $0))[-1];

but I was curious to know if there is a built in that would do this same routine for me?

humbly -c

Replies are listed 'Best First'.
Re: perl internal for present script without full path?
by dsb (Chaplain) on Jul 24, 2001 at 22:35 UTC
    perldoc File::Basename
    That module has functions to return the path and the filename seperately.

    Amel - f.k.a. - kel

Re: perl internal for present script without full path?
by miyagawa (Chaplain) on Jul 24, 2001 at 22:50 UTC
Re: perl internal for present script without full path?
by MZSanford (Curate) on Jul 25, 2001 at 14:19 UTC
    Both of the above posts cover how to split the information up, but i assume you can do that (per the split in your post) ... i checked through the debugger, and, as suspected, there is not internal variable ... sorry, but $0 is all she wrote.
    Thus spake the Master Programmer:
    "When you have learned to snatch the error code from the trap frame, it will be time for you to leave."
    -- The Tao of Programming