in reply to split string and always get last word
Your strings look like paths. If this is the case, you can make your code nicely portable by using File::Spec. Example:
use File::Spec; my $path1 = "./t2"; my $path2 = "/alex/samsung/t2"; my $end1 = ( File::Spec->splitdir($path1) )[-1]; my $end2 = ( File::Spec->splitdir($path2) )[-1]; print "Found $end1 at the end of $path1\n"; print "Found $end2 at the end of $path2\n";
|
|---|