in reply to Re^2: get file name?
in thread get file name?
Or of course there is split
not to mention substr and rindexmy $file_name = ( split m{/}, $0 )[-1];
if you insist on regular expressions then this is simplermy $file_name = substr $0, 1 + rindex $file, '/';
my ( $file_name ) = $0 =~ m{([^/]+)$};
If you care about portability, and one day you will, even if its just to port your code back into your brain in six months time, you will stick to Corion's suggested
use File::Basename qw(basename); my $file_name = basename $0;
|
|---|