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:
push @{$results{$addr}},[@output];
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:
my @a = $results{$addr};
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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.