This is an interesting point.
I looked at toke.c in the perl source and found that OPERATOR(',') is generated for both "," and "=>". I jumped to the conclusion that they must be identical. But then I tried the following:
use strict; use warnings; use Data::Dumper; use constant FOO => "something"; my %h = ( FOO => 23, FOO , 24 ); print Dumper(\%h); __END__ $VAR1 = { 'FOO' => 23, 'something' => 24 };
So they are in fact different, despite the same token being returned from toke.c. Something higher up must look again at what the input text was to decide what to do, but I don't know where this happens.
update: The distinction is in toke.c, not when scanning "," or "=>" but when scanning a word. After scanning a word, toke.c looks ahead and, if it sees "=>" it returns TERM(WORD).
In reply to Re^2: Clarifying the Comma Operator
by ig
in thread Clarifying the Comma Operator
by ig
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |