in reply to Re: Clarifying the Comma Operator
in thread Clarifying the Comma Operator
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).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Clarifying the Comma Operator
by Marshall (Canon) on Jun 07, 2009 at 00:45 UTC | |
|
Re^3: Clarifying the Comma Operator
by lakshmananindia (Chaplain) on Jun 08, 2009 at 05:23 UTC | |
by ig (Vicar) on Jun 08, 2009 at 05:41 UTC |