New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assigning to a list assignment #702
Comments
From mjtg@cus.cam.ac.uk perl -wle '(@a = (1,2,3)) = (4,5);print @a' Where's that undef coming from ? And I can't find any documentation of the result of a list assignment in Mike Guy % perl -V Characteristics of this binary (from libperl): |
From @tamiasOn Tue, Oct 12, 1999 at 05:39:03PM +0100, M.J.T. Guy wrote:
Intriguing! Basically, you're assigning a list of two elements to a list Compare to: @a[0,1,2] = (4,5); Whether this is the desired behavior or not, I couldn't say! :) Ronald |
From [Unknown Contact. See original ticket]ts <decoux@moulon.inra.fr> wrote to me privately
Duh! Of course it is. So the bug report can be closed Mike Guy Inline Patch--- ./pod/perlop.pod.orig Sun Mar 28 00:04:48 1999
+++ ./pod/perlop.pod Wed Oct 13 04:18:25 1999
@@ -501,9 +501,9 @@
Note that while these are grouped by family, they all have the precedence
of assignment.
-Unlike in C, the assignment operator produces a valid lvalue. Modifying
-an assignment is equivalent to doing the assignment and then modifying
-the variable that was assigned to. This is useful for modifying
+Unlike in C, the (scalar) assignment operator produces a valid lvalue.
+Modifying an assignment is equivalent to doing the assignment and then
+modifying the variable that was assigned to. This is useful for modifying
a copy of something, like this:
($tmp = $global) =~ tr [A-Z] [a-z];
@@ -516,6 +516,11 @@
$a += 2;
$a *= 3;
+
+Similarly, a list assigment in list context produces the list of
+lvalues assigned to. But list assignment in a scalar context returns
+the number of elements produced by the expression on the right side of
+the assignment.
=head2 Comma Operator
End of patch |
Migrated from rt.perl.org#1604 (status was 'resolved')
Searchable as RT1604$
The text was updated successfully, but these errors were encountered: