#!/usr/bin/env perl use strict; use warnings; use autodie; @allfiles = ; foreach $file (@allfiles) { open (FILE ,"<", "Myfile"); ###-reads each line from the file and splits it by multiple spaces while($lines=) { @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; }