"Chas Owens" schreef:
> Dr.Ruud:
>> Some evaluation is done first:
>>
>> perl -Mstrict -MData::Dumper -wle'
>> $_ = {0b1_0 => "A", 01_0 => "B", 0x1_0 => "C", 1_0 => "D", _1_0 =>
>> "E", *_ => "F", \_ => "G"};
>> print Dumper $_
>> '
>> $VAR1 = {
>> '8' => 'B',
>> '_1_0' => 'E',
>> '*main::_' => 'F',
>> '10' => 'D',
>> '16' => 'C',
>> 'SCALAR(0x8062850)' => 'G',
>> '2' => 'A'
>> };
> snip
>
> Nope, it has nothing to do with evaluation.
Ah, you misunderstood my "evaluation" which had nothing to do with
eval(). Maye I should have used "parsing and compiling".
> The trick is that it only
> works on barewords (matches /[_A-Za-z][_A-Za-z0-9]*/). 0b1_0 is not a
> bareword because it starts with a number. The same goes for 01_0,
> 0x1_0, and 1_0. _1_0 works because barewords may start with an
> underscore. *_ and \_ are definitely not a barewords since they
> contain characters that are not even in the allowed set. Anything
> that fails the bareword test is treated as if the '=>' operator were a
> normal ',' operator.
Yes, "passing the bareword test" is a better phrase than only mentioning
"word" characters.
There are border cases though:
perl -Mstrict -MData::Dumper -wle'
$_ = { AB => 1, +AB => 2, -AB => 3 };
print Dumper $_
'
$VAR1 = {
'-AB' => 3,
'AB' => 2
};
IIRC, there was a recent related discussion on p5p about this all.
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/