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

$filepath = '/u/test/global/filename.txt'; my ( @data ) = split /\//, $filepath; my ( $filename ) = $data[$#data]; print "$filename" ; ## will print filename.txt

Replies are listed 'Best First'.
Re: Answer: How do I extract a file name from a path string
by TedPride (Priest) on Oct 09, 2004 at 19:59 UTC
    my $filepath = '/u/test/global/filename.txt'; my $fname = substr($filepath, rindex($filepath, '/') + 1);
Re: Answer: How do I extract a file name from a path string
by TVSET (Chaplain) on Oct 09, 2004 at 17:04 UTC
      <br>'s removed now.