ricky5ive has asked for the wisdom of the Perl Monks concerning the following question:
The script I'm working on now that will do it for each file in the directory:open (FILE ,"<", "Myfile"); while($lines=<FILE>) { ###-reads each line from the file and splits it by multiple spaces @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;
I can't figure this out on my own for some reason, but I can't learn without asking for help. Thank you.@allfiles = <C:/Users/user/Desktop/DOwork/filez/nabillingscript/09_14_ +2012/nas/*>; foreach $file (@allfiles) { open (FILE ,"<", "$file"); while($lines=<FILE>) { my $sumof = 0; @kbused = split(/\s+/,$lines); push(@kilo, $kbused[2]); foreach $aline (@kilo) { $aline =~ s/\D//g; push (@onlynums, $aline); $sumof += $_ for @onlynums; } } print "$sumof\n"; } close FILE;
|
|---|