in reply to bareword hash keys

Just cause I dealt with it last week, using a . also causes problems as the . gets eaten and doesn't become part of the key.

Simple example:
$var{test.dot} = "a"; print keys %var;
prints testdot.

I know it's becuase of the dot operator but it still took my by surprise for a second.

JK

Replies are listed 'Best First'.
Re^2: bareword hash keys
by Aristotle (Chancellor) on Jun 30, 2003 at 21:39 UTC
    $ perl use strict; my %var; $var{test.dot} = "a"; ^D Bareword "test" not allowed while "strict subs" in use at - line 3. Bareword "dot" not allowed while "strict subs" in use at - line 3. Execution of - aborted due to compilation errors.
    That's why you should use strict.

    Makeshifts last the longest.