develooper Front page | perl.beginners | Postings from December 2002

populating a hash key using a variable

Thread Next
From:
Ian Zapczynski
Date:
December 11, 2002 07:15
Subject:
populating a hash key using a variable
Message ID:
3DF756D8.1080400@quarterleaf.com
Hello all,

I'm obviously making a silly mistake here and would appreciate it if 
someone can point out my error.  I am trying to populate a hash of a 
hash in a while() loop.  Here is what I have:

my $i = 0;

my %hash = ();

while (<EXPR>) {
        $hash{SOMETHING}{$i} = $something;
        $hash{SOMETHING_ELSE}{$i} = $something_else;
        $i++;
}

The $something and $something_else strings are properly defined.  If I 
check if $hash{SOMETHING}{$i} is defined or attempt to print it, it 
appears to be undefined.

How can I do what I want to do properly? 


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About