Secode has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks
Me again ;-) Again thanks to all for their help on my syslog project I think I am now self sustaining and have a better understanding of Hashes etc. I do have one interesting bug probably a simple explanation for the guru's:
I have a simple hash but the last element will not print out unless I put "{why} on the end of it. If I don't put it on or take the "keys" of the last loop the print out just gives me back the hash ref = A B HASH(0x22501c) . Can some one please tell me how to do this properly as I don't think code with bugs is safe code and I might end up with bug ridden results - here is my example:
#c:\perl\bin\perl my %line; $why = ""; $a = A; $b = B; $c = C; $line{$a}{$b}{$c}; $i = 1; for $a (keys %line) { for $b (keys %{$line{$a}}) { for $c (keys %{$line{$a}{$b}}) { print "$a $b $c\n"; } } }
Thanks very much
Pierre
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash code bug
by davorg (Chancellor) on Apr 28, 2006 at 08:21 UTC | |
by reasonablekeith (Deacon) on Apr 28, 2006 at 08:30 UTC | |
|
Re: Hash code bug
by reasonablekeith (Deacon) on Apr 28, 2006 at 09:10 UTC | |
by jonadab (Parson) on Apr 28, 2006 at 13:25 UTC | |
|
Re: Hash code bug
by McDarren (Abbot) on Apr 28, 2006 at 09:17 UTC | |
|
Re: Hash code bug
by gube (Parson) on Apr 28, 2006 at 09:06 UTC |