TASdvlper has asked for the wisdom of the Perl Monks concerning the following question:

Hey All,

I have this piece of code:

for ( @$ref ) { $$_[1] =~ s/V|v//g; $$_[2] =~ s/V|v//g; $myhash{$$_[0]}{$$_[1]} ||= []; push (@{$myhash{$$_[0]}{$$_[1]}}, $$_[2]); } foreach my $project ( sort keys %myhash ) { foreach my $rel ( $myhash{$project}) { . . . } }
But when I try to print out $ref, i'm getting a reference pointer and not a real value. Not quite sure what I'm doing wrong.

Any thoughts ?

Replies are listed 'Best First'.
Re: Multi-key Hash Table Question
by japhy (Canon) on Jul 28, 2005 at 17:00 UTC
    You want the inner foreach loop to be over sort keys %{ $myhash{$project} }.

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
Re: Multi-key Hash Table Question
by Codon (Friar) on Jul 28, 2005 at 21:49 UTC
    use strict; use warnings;
    These are your friends. They will tell you that %mhash must have an explicit package name, which tells you that you aren't referencing the same "myhash" thingy that you built above.

    Ivan Heffner
    Sr. Software Engineer, DAS Lead
    WhitePages.com, Inc.