in reply to split string and always get last word

Use a list slice.

my $last = ( split '/', $str )[ -1 ];

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊