in reply to sumof - attempting to sum a column from each file

Well, there are issues with your second script that others have pointed out, but why not just put the first one (which you say works) inside a loop that loops through 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
    Thank you very much. I'm going to review each of your responses and soak it all in and then reply with more.
Re^2: sumof - attempting to sum a column from each file
by ricky5ive (Initiate) on Sep 14, 2012 at 23:17 UTC
    Using strict and warnings has a lot of issues with my variable names. Not something I usually use, but obviously I need to get into the practice of.
      You should just always use them. Even if you rarely write Perl, they will probably save you hours of your life.