Fletch is right -- use File::Basename -- but in the more general case of finding the last token in a string, that regex ought to work:
#!/usr/local/bin/perl
use strict;
my $string = '/one/two and three/and four / and five';
if ($string =~ /.*\/(.*?)$/) {
print "Last token: $1\n";
}
Or you could always split on your token separator and grab the last element in the resulting array. |