in reply to split string and always get last word

Try This
while(<DATA>) { print "$'", if($_ =~ /(.*)\//g); } __DATA__ ./t2 /some/path/to/t3 /some/t2