| www.rodneybeede.com | "I would love to change the world, but they won't give me the source code" - unknown |
It will still work regardless of the calling parent attempting to set $0 to something else in an exec call. This is because Perl always forces $0 to the value given when you passed in a script for it to run. This code also resolves any relative pathnames to their absolute counter parts.
my $scriptDirectory = File::Basename::dirname(File::Spec->rel2abs($0)); my $scriptFilename = File::Basename::basename(File::Spec->rel2abs($0));