in reply to Make things a *little* easier
in thread a farewell to chop
Or, how about this, using lvalue substr:
Update: 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.$str = 'abcde'; substr($str, -1) = ''; print $str, $/;
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Make things a *little* easier
by John M. Dlugosz (Monsignor) on Sep 12, 2002 at 14:49 UTC | |
by mdillon (Priest) on Sep 12, 2002 at 15:37 UTC | |
by Aristotle (Chancellor) on Sep 12, 2002 at 16:06 UTC | |
by John M. Dlugosz (Monsignor) on Sep 12, 2002 at 20:03 UTC |
In Section
Meditations