in reply to Reading specific files
You say that the files of interest don't have an extension, but your grep is matching only files with the extension .txt. The first step is to change your grep to:
my @files = grep /^R/, readdir( DIR );
to match files that start with R. The ^ matches the start of the string thus the R requires that the first character be R. When you have the correct list of files the open should be trivial, but remember that the names returned by readdir don't include the directory path so, if the files are not in the current working directory, you will need to prefix $directory to the file names in the open. Probably something like:
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^2: Reading specific files
by jwkrahn (Abbot) on Sep 22, 2009 at 00:29 UTC | |
|
Re^2: Reading specific files
by molson (Acolyte) on Sep 21, 2009 at 23:35 UTC |