Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

(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! ;)


(the triplet paradiddle with high-hat)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://234147]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2019-02-19 04:23 GMT
Find Nodes?
    Voting Booth?
    I use postfix dereferencing ...

    Results (101 votes). Check out past polls.