We don't bite newbies here... much | |
PerlMonks |
Counting the elements of a hash of arrays of arraysby Clownburner (Monk) |
on May 14, 2003 at 18:40 UTC ( [id://258198]=perlquestion: print w/replies, xml ) | Need Help?? |
Clownburner has asked for the wisdom of the Perl Monks concerning the following question:
Oh wise monks, I have toiled at this question and can't seem to get it. I have a data structure that's a hash consisting of an array of arrays, created like this: I need to get the count of how many elements are in the lowest level of this structure (that is, how many @outputs are there in the hash $results{$addr}). I've tried a lot of solutions, and none seem to work. This: returns an array with a single element, that then contains all the @output's. But if I try to 'scalar @a' I get '1', and if I scalar @a[0] or scalar($a[0]) I get a bunch of ARRAY refs. $a = $results{$addr}[0] returns what appears to be an array ref in $a, but scalar(@$a) doesn't return anything, oddly. No more direct manipulation of $results{$addr} seems to result in anything usable... If I do scalar @$results{$addr} I get 'Variable "$results" is not imported'. If I try print scalar $results{$addr} I get a list of array refs again. I'm quite frustrated and though I feel I'm missing something simple, I can't figure out what the heck it might be. All help appreciated. "Non sequitur. Your facts are un-coordinated." - Nomad
Back to
Seekers of Perl Wisdom
|
|