Hofmater set you straight, but i feel inclined to offer
two more tips:
-
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;
-
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)
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.