in reply to Re: Reading specific files
in thread Reading specific files
Don't steal. Stolen goods often have nasty baggage. In this case strict is missing, there is no error checking on the opendir, package variables rather than lexical variables are being used and the various open issues that may face the OP are not addressed. A better version of the code is:
use strict; use warnings; opendir my $scanDir, $directory or die "Unable to open directory $dire +ctory: $!\n" my @files = grep /^R/, readdir $scanDir; closedir $scanDir; for my $filename (@files) { open my $inFile, '<', "$directory/$filename" or die "Can't open $d +irectory/$filename: $!"; ... close $inFile; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Reading specific files
by raisputin (Scribe) on Sep 22, 2009 at 16:22 UTC |