in reply to sumof - attempting to sum a column from each file
#!/usr/bin/env perl use strict; use warnings; use autodie; @allfiles = <C:/Users/user/Desktop/DOwork/filez/nabillingscript/09_14_ +2012/nas/*>; foreach $file (@allfiles) { open (FILE ,"<", "Myfile"); ###-reads each line from the file and splits it by multiple spaces while($lines=<FILE>) { @kbused = split(/\s+/,$lines); push(@kilo, $kbused[2]); } ####-takes the number from column2 and removes the KB from the end foreach $aline (@kilo) { $aline =~ s/\D//g; push (@onlynums, $aline); } $sumof += $_ for @onlynums; print "$sumof\n"; close FILE; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sumof - attempting to sum a column from each file
by ricky5ive (Initiate) on Sep 14, 2012 at 17:27 UTC | |
|
Re^2: sumof - attempting to sum a column from each file
by ricky5ive (Initiate) on Sep 14, 2012 at 23:17 UTC | |
by frozenwithjoy (Priest) on Sep 15, 2012 at 00:29 UTC |