On Wed Oct 29 10:59:37 2003, ysth wrote: > On Wed, Oct 29, 2003 at 08:08:37AM +0000, Graham Barr > <gbarr@pobox.com> wrote: > > On Oct 29, 2003, at 5:55, Yitzchak Scott-Thoennes wrote: > > >On Wed, Oct 29, 2003 at 02:06:12AM -0000, "perl-5.8.0@ton.iguana.be > > >(via RT)" <perlbug-followup@perl.org> wrote: > > >>Sure, I can see what's going on here from an implementation point > of > > >>view, and the substr docs are pretty unspecific on this, so I > can't > > >>absolutely claim it as a bug. But it feels wrong to me to be able > to > > >>pull in stuff from outside the [0..3] range of the original string > > >>into the substr window. Assigning something to a variable and have > it > > >>be different as a result is hardly normal lvalue behaviour. > > >>(what happens to $a is as expected in all cases). I think it > should > > >>not only narrow or expand the original string as needed, but also > > >>the range of the substr alias itself. > > > > > >Yes, I'd like to see this addressed for 5.10.0. Issues need to be > > >worked out for how it should work with negative offset or length. > > > > Why would negative offsets be an issue ? When the LV is created any > > negative offset is resolved and the LV is created with an absolute > > offset and a length. > > That is how it is now, yes. But I can see a case for storing the > negative > values instead for situations like this: > > perl -wle'$x = "abcdef"; for (substr($x,-4,-1)) { chop$x; chop$x; > print $_ }' > Unfortunately this never was addressed for 5.10.0. It is getting in the way of other bugs, such as this: sub myprint { print @_ } print substr("", 2); # warning myprint substr("", 2); # error so I’m working on it for 5.15.6. See <http://www.nntp.perl.org/group/perl.perl5.porters/;msgid=63562EAE-84D6-48BF-8564-7AEE9504482D@cpan.org>. (I’m adding it to this ticket mainly for future reference.) -- Father ChrysostomosThread Previous | Thread Next