Taking a reference to an enumerated list is not the same as using square brackets--instead it's the same as creating a list of references!The special case talks about returning a list of references to the contents of @foo, but it seems more like it returns a reference to a list (whose contents are copied from @foo). It Did What I Meant in the original code, but the documentation seems a little fuzzy to me. Further illumination appreciated.As a special case, \(@foo) returns a list of references to the contents of @foo, not a reference to @foo itself. Likewise for %foo, except that the key references are to copies (since the keys are just strings rather than full-fledged scalars).@list = (\$a, \@b, \%c); @list = \($a, @b, %c); # same thing!
#!/usr/bin/perl -w use Data::Dumper; $ref=\(1..3); $enum_list_ref=\(1,2,3); @a=(\(1..3),\(5..9)); print "\n".Dumper($ref)."\n"; print "\n".Dumper($enum_list_ref)."\n"; print "\n".Dumper(\@a)."\n";
In reply to list references by sleepingsquirrel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |