Randal L. Schwartz wrote:
>
> ""Dr" == Ruud" <rvtol> writes:
>>
>> <quote src="perlop">
>> The "=>" operator is a synonym for the comma, but forces any word to
>> its left to be interpreted as a string (as of 5.001).
>> </quote>
>>
>> And AFAICS that isn't true:
>>
>> $ perl -MData::Dumper -wle'
>>   %n = (00 => Integer, 01 => Floating, 10 => Char, 11 => Double);
>>   print Dumper(\%n)
>> '
>> $VAR1 = {
>>           '11' => 'Double',
>>           '1' => 'Floating',
>>           '0' => 'Integer',
>>           '10' => 'Char'
>>         };
>>
>> So I filed a bug-report about perlop.
>
> Why?  What makes 01 and 00 a "word"?
>
> It's acting correctly.  You just need the correct definition of word.

This is indeed a documentation bug. perlop says, in full:

~ The "=>" operator is a synonym for the comma, but forces any word (consisting
~ entirely of word characters) to its left to be interpreted as a string (as of
~ 5.001). This includes words that might otherwise be considered a constant or
~ function call.

Now '01' consists entirely of /\w/ characters, and certainly might 'otherwise be
considered a constant', yet it provides the hash key '1'. The version in the
Camel is correct:

~ The => digraph is mostly just a synonym for the comma operator. It's useful
~ for documenting arguments that come in pairs. It also forces any identifier to
~ its immediate left to be interpreted as a string.

And we know '01' isn't a Perl identifier so we no longer expect it to be
interpreted as a literal hash key.

perlop needs updating.

Rob




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to