Since others have answered the question you asked, I thought I would answer one that you didn't.<grin/>
Often the simplest way to process more than one file is to pass those files to your script on the command line. Then you can use one of Perl's built-in features to make your life easier. In the code below, I've removed the open() call for the read file and changed your while loop.
#!/user/bin/perl open (OUTFILE, '>> COID_LIST.txt') or die "Unable to open Write File!\ +n$!"; while (<>) { my $COMPANY_ID = substr $_, 260, 5; push @COMPANIES, {comp => $COMPANY_ID}; } foreach (@COMPANIES) { $sum{$_->{'comp'}} += $_->{'count'}; } #Output in %sum use Data::Dumper; print OUTFILE Dumper(\%sum); close OUTFILE;
The resulting code is called with the list of files to process on the command line. The code will then process the files from the command line, one at a time until complete. This approach can simplify some problems.
In reply to Re: Opening multiple files in directory
by gwadej
in thread Opening multiple files in directory
by molson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |