in reply to Re^2: Perl Hash
in thread Perl Hash
Anyway, with that said, you get an error because you've not delcared $k in your foreach loop ala...
Your also emptying your hash with the line...foreach my $k (keys(%LogHash)) { print LOGFILE $k, ",", $LogHash{$k}, "\n"; }
assigning a key with a value would normally be done like this%LogHash = ($HashKey => $SentRec = substr($_, 0, 20));
... but this isn't going to help you much because I'm still not sure what the output of the program should be.$LogHash{%HashKey} = "THEVALUE";
You also seem to think that you can have multiple values for a single key. That's not true, hashes are one key -> one value (that's not to say the value couldn't be an array reference, but that's a whole other topic).
you might also want to take a look at data::dumper, which is great for debugging hashes (by printing them)
good luckuse Data::Dumper; print Dumper(\%hash);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Perl Hash
by TechNoFear (Initiate) on Jul 26, 2005 at 09:33 UTC | |
by davorg (Chancellor) on Jul 26, 2005 at 09:51 UTC | |
by GrandFather (Saint) on Jul 26, 2005 at 09:55 UTC | |
by GrandFather (Saint) on Jul 26, 2005 at 10:15 UTC | |
by Random_Walk (Prior) on Jul 26, 2005 at 10:02 UTC | |
by Iron (Scribe) on Jul 26, 2005 at 09:58 UTC |