Can anyone understand why the two lists output by this test program are different? Note the first word of both lists.
Update: Added the references to the outputs to show they hadn't changed.
Update2: This code won't do anything useful before 5.8.3.
#! perl -slw use strict; my $s = 'the quick brown fox jumps over the lazy dog'; my @wordRefs; print do{ my $ref = \substr( $s, $-[ 0 ], $+[ 1 ] - $-[ 0 ] ); push @wordRefs, $ref; "$ref : $$ref"; } while $s =~ m[(\S+\s*)]g; print $/, '---', $/; print "$_ : $$_" for @wordRefs; __END__ P:\test>subrefs LVALUE(0x182caf8) : the LVALUE(0x1831624) : quick LVALUE(0x18315d0) : brown LVALUE(0x1824334) : fox LVALUE(0x18243f4) : jumps LVALUE(0x1831660) : over LVALUE(0x1831678) : the LVALUE(0x1831690) : lazy LVALUE(0x18316a8) : dog --- LVALUE(0x182caf8) : dog LVALUE(0x1831624) : quick LVALUE(0x18315d0) : brown LVALUE(0x1824334) : fox LVALUE(0x18243f4) : jumps LVALUE(0x1831660) : over LVALUE(0x1831678) : the LVALUE(0x1831690) : lazy LVALUE(0x18316a8) : dog
The first list is produced as the references are stacked. The second is produced from those same references. Why are they different?
In reply to Substr ref anomoly (revisited) by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |