in reply to Re: declaration of variables
in thread declaration of variables
And thus:(cmd.exe has different shell quoting!) %perl -w -Mstrict -e "my ($v) = '';" (no warnings)
which parses in my head as 'string is assigned to first element of the left hand side list'. I can't argue with the exact concepts applied by the interpreter because I forgot most about the weirder rules of context including lvalue stuff. But this seems to support the above:%perl -w -Mstrict -e "my ($v) = 'a'; print $v;" a
Still, string being assigned to first element of the left-hand side list. Same for lists on the right-hand side. (Which would be common usage in contrast to the above weirdness.)%perl -w -Mstrict -e "my ($v,$s) = 'a'; print $v, $s;" aUse of uninitialized value in print at -e line 1.
Good. As expected. Same goes for two-element lists on the rhs.%perl -w -Mstrict -e "my ($v,$s) = ('a'); print $v, $s;" aUse of uninitialized value in print at -e line 1.
And the ',' operator has lower precedence than '=', so we get a 'useless use of a constant' error.%perl -w -Mstrict -e "my ($v,$s) = ('a', 'b'); print $v, $s;" ab
Hope this clarified things a little.%perl -w -Mstrict -e "my ($v,$s) = 'a', 'b'; print $v, $s;" Useless use of a constant in void context at -e line 1. aUse of uninitialized value in print at -e line 1.
|
|---|