open (FILE ,"<", "Myfile"); while($lines=) { ###-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; #### @allfiles = ; foreach $file (@allfiles) { open (FILE ,"<", "$file"); while($lines=) { 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;