Skip to content

Commit 5d65e37

Browse files
committed
document ref assignment in list context
The 'refaliasing' feature, whereby assigning to a literal reference causes an aliasing operation (e.g. \$x = \...) didn't document what was returned if the assignment was done in list context. This commit adds a basic summary to the docs. See the thread http://nntp.perl.org/group/perl.perl5.porters/267074 for the discussion.
1 parent 0fc8a78 commit 5d65e37

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pod/perlref.pod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,16 @@ for obfuscated code:
865865
my $type = ref $thingy;
866866
($type ? $type eq 'ARRAY' ? \@foo : \$bar : $baz) = $thingy;
867867

868+
A reference assignment in list context returns a list of references to
869+
each left-hand value. So for example
870+
871+
@b = ((\$l1, \$l2, \(@a)) = (\$r1, \$r2, $\r3, \$4));
872+
873+
is equivalent to
874+
875+
(\$l1, \$l2, \(@a)) = (\$r1, \$r2, $\r3, \$4);
876+
@b = (\$l1, \$l2, \$a[0], \$a[1]);
877+
868878
The C<foreach> loop can also take a reference constructor for its loop
869879
variable, though the syntax is limited to one of the following, with an
870880
optional C<my>, C<state>, or C<our> after the backslash:

0 commit comments

Comments
 (0)