in reply to Replace the last letter

In the 'yet another way to do it' category:
my $tofind="s"; my $replacement="X"; my $variable="snaskes"; substr($variable, -1, 1) = $replacement if (substr($variable, -1, 1) e +q $tofind); print "$variable\n";
Trek

Update: Thanks to the CB folks for pointing out the mistake! Edited.

Replies are listed 'Best First'.
Re^2: Replace the last letter
by TrekNoid (Pilgrim) on Oct 07, 2004 at 19:07 UTC
    I noted this got downvoted, which is fine... I'm not seeking argument to that

    I would appreciate knowing, however, why. I'm always wanting to improve my skills, and if I've done something unknowingly wrong here, please let me know so I can correct it in the future

    I think I've shown in the past that I'm willing to learn from my own mistakes when shown why

    Maybe others here take offense to being corrected, but I appreciate it.

    Trek