in reply to
Make things a *little* easier
in thread a farewell to chop
Or, how about this, using lvalue substr:
$str = 'abcde';
substr($str, -1) = '';
print $str, $/;
: just in case anyone was wondering (as Solo
did in a /msg), this is real Perl 5 code. I believe lvalue substr
was added in some patchlevel release of Perl 5.005.
Update^2: the advantage this has over the 4-arg substr is that you don't need to put the number of chars to replace in the string (which would always be the absolute value of the negative offset in situations like this); it just replaces everything up through the end of the string.