in reply to Replace the last letter

not sure if that is really elegant or effective (compared to a regex), but it was the first thing that came to my mind:
my $tofind="s"; my $replacement="X"; my $variable="snaskes"; my $tmp = chop $variable; $variable .= $tmp eq $tofind ? $replacement : $tmp; print $variable;