in reply to Opening multiple files in directory

The naive response is that you must open each file individually for I/O. By 'tried using open MYDIR "." and foreach to iterate through the files', do you mean you tried something like the following?

#!/user/bin/perl open (OUTFILE, '>>', 'COID_LIST.txt') or die "Unable to open Write Fil +e! \n$!"; opendir MYDIR, '.' or die "opendir $dir_name failed"; my @file_list = readdir(MYDIR); closedir MYDIR, '.' or die "opendir $dir_name failed"; foreach $file (@file_list) { open (INFILE, '<', $file) or die "File not found\n$!"; while (<INFILE>) { my $COMPANY_ID = substr $_, 260, 5; push @COMPANIES, {comp => $COMPANY_ID}; } close INFILE; } foreach (@COMPANIES) { $sum{$_->{'comp'}} += $_->{'count'}; } #Output in %sum use Data::Dumper; print OUTFILE Dumper(\%sum); close OUTFILE;

Note that I changed to the three-argument form of open - this is particularly important if your take in a list of files. You should also get into the habit of starting files with use strict;use warnings since it'll save you from typos.