Help for this page

Select Code to Download


  1. or download this
    $ perl -wMstrict -le '"/foo/bar/baz/bat"=~/\/(.+)\//; print $1'
    foo/bar/baz
    $ perl -wMstrict -le '"/foo/bar/baz/bat"=~/\/(.+?)\//; print $1'
    foo
    
  2. or download this
    use File::Basename 'fileparse';
    my $filename = fileparse("/foo/bar/baz/bat");
    print "$filename\n";
    __END__
    bat