in reply to Isolating a file name

use strict; use warnings; use File::Basename; my $s = "/home/virtual/path/to/www/some/directory/filename.txt"; print basename($s,'.txt') . "\n";

Scott

Replies are listed 'Best First'.
Re^2: Isolating a file name
by helphand (Pilgrim) on Feb 04, 2006 at 19:53 UTC

    It occurs to me that if you don't know the extension in advance, this approach would be more flexible.

    use strict; use warnings; use File::Basename; my $s = "/home/virtual/path/to/www/some/directory/filename.txt"; my ($base,$path,$ext) = fileparse($s,'\..*'); print "$base\n";

    Scott