10/15 Can you use the "correspond" operator (=>) in perl to initialize a
a 2D hash? I'm getting some wierd errors. Thanks.
\_ For major funky data structures and how to build and access them
read ~scotsman/bin/SearchReport. Also, use Data::Dumper to see
what you've actually created/accessed.
\_ hm... I just want to do this, essentially:
my %myHash = (
"a" => ( "1" => "foo",
"2" => "bar" ),
"b" => ( "1" => "baz",
"2" => "shlep" )
);
\_ All your ()'s here should be {}'s. --scotsman
\_ All your ()'s here should belong to {}'s. --scotsman
\_ Actually, I got it to work by replacing all but the outer-
most parens with {}. I'm still not clear on when Perl
wants an even-length list, and when a map... but oh well...
I guess the code works for now. Thanks alot.
\_ You should really use {}'s. These designate specfically
that these are HASHES. If you may eventually add a
third dimension, this will trip you up again. Hashes
are basically glorified arrays, which is why your first
attempt was so confusing. Say what you mean and mean
what you say. --scotsman
\_ Almost right, except that the poster had %myHash
instead of $myHash, so in this case ()'s would be
correct for the outermost set. {} designates
anonymous hashes and returns a scalar (a
reference to an anonymous hash). -geordan
\_ Make everything a global variable! |