in reply to Re^2: sumof - attempting to sum a column from each file
in thread sumof - attempting to sum a column from each file
It uses the magic attached to the ARGV filehandle which automatically iterates over all lines of all filenames in @ARGV.use Modern::Perl; my $sum_of_used; @ARGV = <C:/Users/user/Desktop/DOwork/filez/nabillingscript/09_14_2012 +/nas/*>; { no warnings qw/numeric uninitialized/; $sum_of_used += (split /\s+/)[2] while <ARGV>; } say $sum_of_used;
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: sumof - attempting to sum a column from each file
by ricky5ive (Initiate) on Sep 18, 2012 at 01:18 UTC | |
by CountZero (Bishop) on Sep 18, 2012 at 06:20 UTC |