Hi all,
I am past the point of braking and in so I turn to the people that will know.
I have looked over the Q/A but unless I missed it I didn’t see an answer?
My problem:
I currently have a hash of arrays. I can find the number of keys in the hash but I wish to find the number of element in each array?
I have constructed the hash using
push @{$FULLLINES{$account}}, “$lines”;
I have managed to count lines using the below solution but I am sure its not ideal.
Is there a proper way of doing this?
I have tried all different types of array length test and hash length test but I can’t find the one for me.
foreach $key (sort keys %FULLLINES){
$CCOUNT = 0;
print "key = $key\n";
if ($key eq "N/A") {next;}
foreach $fullline (@{$FULLLINES{$key}}) {
$CCOUNT++
}
$num = $CCOUNT;
if ($num <= 1) {
print "account number for $key listed $num times\n";
} else {print "Account $key is listed:$num times\n";}
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.