in reply to Simple Regex needed

Don't use a regex. Be portable. Use File::Basename:
use File::Basename; my $file = basename($full_path);

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: Simple Regex needed
by paulbort (Hermit) on May 09, 2003 at 15:55 UTC
    Just for completeness, the way I've been doing it (because I didn't know about File::Basename either) is this:
    my ( $basename ) = reverse split /\//, "/tmp/app/foo";

    Now I'm going to go back and change my code to use File::Basename. Thanks, merlyn!

    --
    Spring: Forces, Coiled Again!
      > my ( $basename ) = reverse split /\//, "/tmp/app/foo";

      The only problem with this is that it's not portable: it'll work on Unix, but probably not on MS Windows.