in reply to Replace the last letter

This is a no brainer. There are many solutions.

# reverse the string and replace first occurance
# since no monk has suggested this simple solution yet.
$variable = reverse $string; $variable =~ s/$tofind/$replace/; $variable = reverse $string;