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

Seekers of Perl Wisdom
  • Comment on Hash reference problem (hash ref stored in another hash)

Replies are listed 'Best First'.
Re: Hash reference problem (hash ref stored in another hash)
by chromatic (Archbishop) on Sep 07, 2000 at 19:42 UTC
    You're storing a string, not a hash reference. A list of lists would be better:
    @FreqListInfoTmp = ( [ 1, \%HourCalledFreq, "Hours of day calls were made" ], [ 2, \%DateFreq, "Dates calls were made" ], [ 3, \%CallFreq, "How many callers called how many times" ], [ 4, \%DaysOnlineFreq, "How many days callers were online for" ], [ 5, \%HoursOnlineFreq, "How many hours callers were online for" ] +, [ 6, \%MinsOnlineFreq, "How many mins callers were online for" ], [ 7, \%ClipsVisitedMaster, "How many times which clips were visite +d" ], [ 8, \%CallsMaster, "Detailed info on each caller" ] ); foreach my $list (@FreqListInfoTmp) { $FreqListInfo{$list->[0]}{NO} = $list->[0]; $FreqListInfo{$list->[0]}{HASH} = $list->[1]; $FreqListInfo{$list->[0]}{DESC} = $list->[2]; }
    Untested, but if you've read perldsc you'll understand.
Re: Hash reference problem (hash ref stored in another hash)
by tye (Sage) on Sep 07, 2000 at 20:07 UTC

    chromatic is correct (of course). To add a few details, % is not "special" inside double quotes so "\%" is the same as "%"; the \ (unnecessarilly) escapes the %. And "%x" is the same as "%"."x", that is, it doesn't do anything with any hash called %x. This is in contrast to "$x" and "@x", both of which interpolate variables (though "@x" has some history behind it where it didn't interpolate unless @x existed at compile time and now generates an error for this case).

    Note that while "$x" is the same as "".$x, "\$x" is not the same as "".\$x. [ This is in part because "".\$x isn't that useful (producing "SCALAR(0x1b1d9ec)"); in particular, given "".\$x, there is no good way to get to $x. ] "\$x" is the same as "\$"."x" which is the same as '$'."x" or just '$x', that is, a string containing a $ followed by an x. Likewise "\@x" is the same as '@x'.

            - tye (but my friends call me "Tye")