Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

(jeffa) Re: Finding the size of an array in a hash?

by jeffa (Bishop)
on Feb 10, 2003 at 15:36 UTC ( #234147=note: print w/replies, xml ) Need Help??


in reply to Finding the size of an array in a hash?

Hofmater set you straight, but i feel inclined to offer two more tips:
  1. push @{$FULLLINES{$account}}, “$lines”;
    Don't put quotes around $lines -- this is habit that will get you into trouble when you start dealing with references. Besides, the quotes are completely superficial since they will allow the contents to evaluate to the ... contents, namely, the variable $lines. Use this instead:
    push @{$FULLLINES{$account}}, $lines;
  2. Learn how to format. Get a copy of PerlTidy if you have to. Having to count braces to determine where scope starts and ends is no fun for an experienced programmer. If you want to play with the big dogs, dress the part!
Here is your above code, reformatted for clarity and corrected (you left out the closing brace for the very first foreach).
foreach $key ( sort keys %FULLLINES ) { $CCOUNT = 0; print "key = $key\n"; next if $key eq "N/A"; $CCOUNT++ for @{$FULLLINES{$key}}; $num = $CCOUNT; if ( $num <= 1 ) { print "account number for $key listed $num times\n"; } else { print "Account $key is listed:$num times\n"; } }
Oh yeah .... one more tip: USE STRICT! ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://234147]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2018-07-18 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (383 votes). Check out past polls.

    Notices?