Yes. This is a recursive consequence of the rule that any list can end
with a comma, which is ignored. And the fact that lists don't require
parens around them unless required by precedence. So don't take the
absence of parentheses for the absence of a list.
So your example is parsing as all these sublists:
($a = 1),(),(),(),(),(),(),(),()
which, after you interpolate all the null lists, is just the list
($a = 1)
which is, of course, no different from
$a = 1
: The camel says these are wrong (so I'm told; p528?):
That's talking specifically about putting a comma between a filehandle
and subsequent arguments.
: print $a, if s/x/y/;
: print, if s/x/y/;
: Yet perl accepts them.
Why not? There are no filehandles there, as far as Perl is concerned.
Just a list of size 1 and a list of size 0, either of which can end
with a comma.
Actually, now that I think about it, you can't actually start a list
with a comma, so the second one is probably parsing as (print),()
rather than print((),()). In which case that's a list of size 1 as well,
the first and only element of which is the bare print operator. After all,
if you said
print, next if s/x/y/
it would print $_ and then do a next, since next would not be considered
an argument to the print. That's why we don't allow lists to start with
But they may certainly end with one. And since a list that ends with
a comma is a list, it can in turn end with a comma. And since a list
that ends with two commas is a list, it can in turn end with a comma.
Und so weiter...
Migrated from rt.perl.org#2053 (status was 'resolved')
Searchable as RT2053$
The text was updated successfully, but these errors were encountered: