Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^3: sumof - attempting to sum a column from each fileby CountZero (Bishop) |
on Sep 15, 2012 at 07:14 UTC ( [id://993845]=note: print w/replies, xml ) | Need Help?? |
Try this for your summing code: It can be so simple because Perl knows how to make a number out of "almost" numbers. In other words, Perl simply disregards the 'KB' which is attached to the number. Everything which does not contain numbers will become 0, such as the header line. A perfect example of Perlish "Do What I Mean". Of course I had to switch of the "not numeric" and "not initialized" warnings, but that is OK if you know what you are doing. CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James My blog: Imperial Deltronics
In Section
Seekers of Perl Wisdom
|
|