in reply to Syntax Error using STRICT and Declaring Variable

my's argument must be a variable name, or a list of variables in parens.
@chicago{   qw(tiger bob munch toy)    }
is neither. I'm afraid you'll have to do

my %chicago; @chicago{ qw( tiger bob munch toy ) } = (); my %wisconsin; @wisconsin{ qw( tiger sara munch toy ) } = (); my %rockford; @rockford{ qw( tiger sara love toy ) } = ();

or

my %chicago = map { $_ => undef } qw( tiger bob munch toy ); my %wisconsin = map { $_ => undef } qw( tiger sara munch toy ); my %rockford = map { $_ => undef } qw( tiger sara love toy );

or even better (since you won't have to use exists)

my %chicago = map { $_ => 1 } qw( tiger bob munch toy ); my %wisconsin = map { $_ => 1 } qw( tiger sara munch toy ); my %rockford = map { $_ => 1 } qw( tiger sara love toy );

Replies are listed 'Best First'.
Re^2: Syntax Error using STRICT and Declaring Variable
by diotalevi (Canon) on Feb 02, 2006 at 07:13 UTC

    Double-plus ungood for even suggesting those map solutions. Gawd. This is TIMTOWDI taken far too far. The first suggestion was the best by far.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊