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; }

True laziness is hard work

Replies are listed 'Best First'.
Re^3: Reading specific files
by raisputin (Scribe) on Sep 22, 2009 at 16:22 UTC
    Fair enough, I just assumed (ya, I know) the OP would use strict as that is standard practice... As for the rest, it was just cut-n-paste but it worked. I was tempted to just say change it to /^R/ but whatever. Live and learn :)