Why do references always trip me up? I tend not to use them greatly and always struggle when I do. Context: I was trying to make a subroutine return a reference to a slice of an array. I wrote
\@array[0..3]
which just returned a reference to a scalar before finding what I needed was
[@array[0..3]]
same problem (Score:2, Informative)
"An array slice is exactly the same as a list of individual array elements. Because you can't take a reference to a list, you can't take a reference to an array slice".
Re:Cookbook (Score:2)
Re:same problem (Score:2)
perl -le '$x="abcdef";$y=\substr $x,2,2;$$y="gh";print $x'
(warning ! this behaviour is not documented ! use at your own risk !)