in reply to Re: Re: Unexpected variable assignment
in thread Unexpected variable assignment
The parenthesis don't construct a list. In this case, the context of the assignment does.
my $scalar = 1, 2, 3; # interpreted as: (my $scalar = 1), 2, 3; my @letters = 'a', 'b', 'c'; # interpreted as: (my @letters = 'a'), 'b', 'c';
The problem here is that the precendence of the assignment is higher than the precendence of the comma. The paranthesis group the constants and help the parser realize that the comma is not separating statements.
Arrays are accessed via containers (variables). Lists aren't.
Arrays may or may not have names -- anonymous arrays are still arrays.
Lists can be stored in arrays, but then they cease to behave as lists.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Unexpected variable assignment
by jonnyfolk (Vicar) on Apr 10, 2003 at 10:48 UTC |