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

True laziness is hard work

Replies are listed 'Best First'.
Re^2: Reading specific files
by jwkrahn (Abbot) on Sep 22, 2009 at 00:29 UTC
    your grep is matching only files with the extension .txt

    molson is using the regular expression  /\.txt/ which will match the string '.txt' anywhere in $_ while a file extention implies that the string will only appear at the end of the string in $_.

Re^2: Reading specific files
by molson (Acolyte) on Sep 21, 2009 at 23:35 UTC
    Sorry about that, I should have clarified that the only way I was able to get my code to work was add the .txt extension to some files.

    the grep /^R/ works great! Thank you!!