P:\test>c:\perl561\bin\perl5.6.1.exe \bin\p1.pl
perl> $bigScalar = 'the quick brown fox jumps over the laxy dog';;
perl> @lvrefs = map{
\substr $bigScalar, $_->[0], $_->[1]
} [0,3], [4,5], [10,5], [16,3], [20,5], [26,4], [31,3], [35,4], [40,3];;
perl> print $$_ for @lvrefs;;
dog
dog
dog
dog
dog
dog
dog
dog
dog
####
perl> $bigScalar = 'the quick brown fox jumps over the laxy dog';;
perl> @lvrefs = map{
eval '\ substr $bigScalar, $_->[0], $_->[1]'
} [0,3], [4,5], [10,5], [16,3], [20,5], [26,4], [31,3], [35,4], [40,3];;
perl> print $$_ for @lvrefs;;
the
quick
brown
fox
jumps
over
the
laxy
dog
####
P:\test>c:\perl5.8.5\bin\perl5.8.5.exe \bin\p1.pl
perl> $bigScalar = 'the quick brown fox jumps over the laxy dog';;
perl> @lvrefs = map{
\substr $bigScalar, $_->[0], $_->[1]
} [0,3], [4,5], [10,5], [16,3], [20,5], [26,4], [31,3], [35,4], [40,3];;
perl> print $$_ for @lvrefs;;
the
quick
brown
fox
jumps
over
the
laxy
dog
perl> ${ $lvrefs[ 4 ] } = 'x';;
perl> print $bigScalar;;
the quick brown fox x over the laxy dog
perl> ${ $lvrefs[ 4 ] } = 'xxxxxx';;
perl> print $bigScalar;;
the quick brown fox xxxxxxr the laxy dog
perl> print $$_ for @lvrefs;;
the
quick
brown
fox
xxxxx
r th
la
y do
####
perl> $s = 'abcde';;
perl> $lv = \ substr $s, 1, 3;;
perl> print $$lv;;
bcd
perl> $$lv = '1234';;
perl> print $$lv;;
123 ## The lvref stil refers to a 3 char substring.
## this could be adjusted to reflect the new length.