note
mdillon
Yes. Using <tt>undef</tt> as the third argument does have that effect. I suspect Perl 6 will improve on this somewhat by being able to do:
<code>substr $str, -1, replace => '';
</code>
This may not seem like much of an improvement, but it gets rid of the <tt>undef</tt>, which could possibly be mysterious to the uninitiated (as could lvalue <tt>substr</tt>).
<p><strong>Update</strong>: yikes! Using <tt>undef</tt> doesn't actually work like this (i.e. as the third arg in a Perl-5 <tt>substr</tt>). I had assumed it did, but it actually acts the same as using 0 as the third arg (at least with 5.8.0). Anyways, the lvalue behavior is stable and documented since 5.6 (possibly earlier); if <tt>undef</tt> works like this in any Perl version, I haven't seen it documented. Sorry for the foolish mistake (and for the unfounded assumption).
196971
197238