On Nov 15, 6:52 pm, [EMAIL PROTECTED] (Kelly Jones) wrote: > Consider: > > perl -le '$hash{"foo-bar"} = 1; print $hash{foo-bar}' > [no result] > > perl -le '$hash{"foobar"} = 1; print $hash{foobar}' > 1 > > I sort of understand this: in the first script, Perl treats foo-bar as > a subtraction, and sets $hash{0} to 1. In the second one it assumes > you just left off some quotes. > > My question: since Perl doesn't have constants
False. > what exactly IS foo-bar? Why is it 0? 'foo' - 'bar' or 0-0 which is zero. > The behavior above seems inconsistent to me. The strict pragma disables 3 features of Perl that can be confusing if you don't realise that you are using them. The warnings pragma warns you of several more features of Perl that can be confusing if you don't realise that you are using them. In this case you are using the features bare-word strings (that would be disabled by strict) and implicit conversion of non-numeric strings to the number zero (that would be warned about by warnings). > Is it considered a bug? The lack of "use strict" and "use warnings" at the top of your code should usually be considered a bug. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/