in reply to Index of the last occurence of a character inside a string

As posters have already said, rindex will work, but there are also regexen.

my $needle = '@'; my $str_index = $text =~ /.*()\Q$needle\E/ && $-[1];