Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
this is in a loop, which defines every line in a file. Each line has a state, a char, a stack_char,.. you get the idea, and then this hash is pushed into an array. this is how i am trying to call it, but with no luck, using -w i get the following error:%rec = (state => $part1[0], char => $part1[1], stack_char => $part1[2], new_state => $part2[0], new_stack_char => $part2[1]); push (@db, %rec);
i assume this isnt really the way to define the hash per value in the array, but.. how can i do this??foreach $hash(@db){ %temphash = $hash; foreach $key( keys %temphash){ print "KEY: $key \n"; print "VALUE: $temphash{$key} \n"; print "________________________\n"; } #end foreach $key }#end foreach $hash
2001-03-11 Edit by Corion : Moved to SOPW (who approved this for discussion ?)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash Array Help
by danger (Priest) on Mar 11, 2001 at 11:27 UTC | |
by Anonymous Monk on Mar 11, 2001 at 11:51 UTC | |
by buckaduck (Chaplain) on Mar 11, 2001 at 21:32 UTC | |
by archon (Monk) on Mar 11, 2001 at 12:13 UTC | |
|
Re: Hash Array Help
by archon (Monk) on Mar 11, 2001 at 11:29 UTC |