Use File::Basename, it is platform independent
use File::Basename qw(basename dirname); my $path = '/usr/local/bin/perl'; my $file = basename $path; # $file eq 'perl' my $dir = dirname $path; # $dir eq '/usr/local/bin'
If you really must do it yourself then
See why I recommend File::Basename?my ($dir, $file) = $path =~ m{^(?:(.*)/)?([^/]+)$}x;
In reply to Re: Parse grep result
by hipowls
in thread Parse grep result
by vsailas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |