in reply to split string and always get last word

You probably want File::Basename.

But if not, a well-suited tool is the often-overlooked rindex:

my $str = '/alex/samsung/t2'; my $last_element = substr($str, rindex($str, '/') + 1); print "$last_element\n";
Note that if the delimiter is not present, you'll get the whole string.

Caution: Contents may have been coded under pressure.