If I do
my $s = 'The quick brown fox jumps over the lazy dog'; print ${ \substr($s, $_, 1) } for 0 .. length($s)-1; # Output The quick brown fox jumps over the lazy dog
Which is what I expected but if I try
my @refs; push @r, \substr($s, $_, 1) for 0 .. length($s) -1; print $$_ for @refs; # Output ggggggggggggggggggggggggggggggggggggggggggg
and if I do
print @refs; # Output LVALUE(0x1bd5270) LVALUE(0x1bd5270) LVALUE(0x1bd5270) LVALUE(0x1bd5270 +) LVALUE(0x1bd5270) LVALUE(0x1bd5270) ...
Which I think indicates that there is only one LVALUE per string. I tried to read the source pp.c(pp_substr) to confirm this, but I'm not familiar enough with perlguts to interpret what I read.
Can anyone confirm my conclusion?
Examine what is said, not who speaks.
The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.
In reply to LVALUE refs by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |