in reply to Problem with substr
if ((my $index = rindex( $name, q{.replaced})) > -1 ) { $name = substr $name, 0, $index; }
Note as well that you have an off-by-one error on your replacement, which I have fixed by adding '.' to your string.
Update: AnomalousMonk caught that the rindex was in the LENGTH argument, not the OFFSET argument. If LENGTH is negative, leaves that many characters off the end of the string.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|