"John W. Krahn" schreef:
> Dr.Ruud:
>> John W. Krahn:
>>> Dr.Ruud:
>>>> 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
>>>> };
>>>
>>> It depends on what you mean by "border case"?
>>
>> Well, I expected both +AB and -AB would trigger a "bareword" error.
>> But also like this:
>>
>> $ perl -Mstrict -wle 'my $x = -XY; print $x'
>>
>> there is no error message.
>>
>>
>> With a "+" it is different though:
>>
>> $ perl -Mstrict -wle 'my $x = +XY; print $x'
>> Bareword "XY" not allowed while "strict subs" in use at -e line 1.
>> Execution of -e aborted due to compilation errors.
>>
>>
>>> Unary plus and unary minus appear to be behaving correctly. :-)
>>
>> Right. :)
>
> perldoc perlop
> -bareword is equivalent to "-bareword"
Yes, but under strict I expect a warning, like with:
$ perl -Mstrict -wle 'my $x = -A; print $x'
Use of uninitialized value in -A at -e line 1.
Use of uninitialized value in print at -e line 1.
$ perl -Mstrict -wle 'my $x = "-A"; print $x'
-A
After all this, I somewhat expected v65 to silently turn into an A :)
but it doesn't:
$ perl -Mstrict -MData::Dumper -wle'
$_ = { A => 1, +A => 2, v65 => 3 };
print Dumper $_
'
$VAR1 = {
'A' => 2,
'v65' => 3
};
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/