in reply to Replace the last letter

I think that a lot of these responses misinterpreted the requirements. The OP is not saying replace the last letter, but instead the last letter of a certain type, i.e. the last 's' or the last 'p' for instance.

Replies are listed 'Best First'.
Re^2: Replace the last letter
by superfrink (Curate) on Oct 07, 2004 at 18:59 UTC
    It seems to me that this was recently posted about on this site.
    #!/usr/bin/perl use strict; my $find = "r"; my $replace = "X"; my $input = "superfrink"; my $tmp = reverse $input; $tmp =~ s/$find/$replace/; my $output = reverse $tmp; print "input: $input \n"; print "output: $output \n";

    Update: Here is the sample output.
    frink@scanbox:~ $ ./397370.pl input: superfrink output: superfXink frink@scanbox:~ $