in reply to Re: How do I extract a file name from a path string
in thread How do I extract a file name from a path string

I'm not sure why I would want to use that code fragment and not File::Spec::Functions.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

  • Comment on Re: Answer: How do I extract a file name from a path string

Replies are listed 'Best First'.
Re^2: Answer: How do I extract a file name from a path string
by legato (Monk) on Jan 18, 2005 at 15:02 UTC

    I wholeheartedly agree:

    use File::Spec::Functions; my $fname = '/home/legato/filename.pl'; my ($vol, $path, $filename) = splitpath($fname); # $filename now contains 'filename.pl'
    A pattern match will not be as platform-aware (or as readable, incidentally) or as thorough as the above code, which is not significantly longer.

    Anima Legato
    .oO all things connect through the motion of the mind