Help for this page

Select Code to Download


  1. or download this
    use File::Basename qw(basename dirname);
    
    ...
    
    my $file = basename $path;  # $file eq 'perl'
    my $dir = dirname $path;    # $dir eq '/usr/local/bin'
    
  2. or download this
    my ($dir, $file) = $path =~ m{^(?:(.*)/)?([^/]+)$}x;