Hello All,

I have a set of gzipped files and I would like to unzip and read the
contents using perl v5.8 and gzcat. The location of gzcat is '/usr/bin/gzcat' and the filenames are in the format:
   batch.shares.2007-07-24.gz
where the date changes but the rest of the name is the same. All the files in the directory are rw-rw-rw so I should be able to read them. I use opendir and readdir to read in all the filenames and then open to read the contents. But what I tried failed to read the file contents.
The following is not the full program, just the section that tries
to open and read the files:

$GZCAT = '/usr/bin/gzcat';
$file_location = '/nfs/workdir/batch/';

opendir(BAT, "$file_location") || die "Cannot open $file_location\n";
while ( $input = readdir BAT ){
  next if $input =~ /^\.\.?$/;   # skip the dot files
  open(IN,"$GZCAT $file_location/$input") || die "Cannot read $input\n";
     while ( my $line = <IN> ){
        # do something
     }
  }
}

opendir and readdir work and get the filenames but open(IN,"$GZCAT $file_location/$input") complains
that it can't read the file. I printed out the line
"$GZCAT $file_location/$input" and then tried it
from the command line and it works so I'm at a loss
why it doesn't work from my script.

Any advice is greatly appreciated.

thanks, Chee

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to