> Can someone tell me how to extract the uncompressed data from the
returned value using the script below? I try and print the $fio
variable, but I get some hash reference. Do I need to iterate through
this hash and then print the values or am I just going about this all
wrong? I am trying to just open the gzip file and read the contents. I
am using this module because I am limed to a box running 5.6.
> 
> Thanks in advance.
> 
> script:
> ===========
> #!/usr/bin/perl
> use IO::Filter::gzip;
> $io = "denver.gz";
> $fio = new IO::Filter::gzip ($io, "r");
> print "$fio\n";
> 
> ouput:
> ===========
> $./test.pl 
> IO::Filter::gzip=HASH(0x8132004)
> 

First I will suggest you should use Compress::Zlib which should be
available for just about any Perl version, and certainly works in 5.6.x.

Having said that, it isn't really what you asked, so I would suggest
taking a look at the base IO::Filter module's documentation, as it
appears that IO::Filter::gzip inherits most of its "good stuff" from
that, it can be found here:

http://search.cpan.org/~rwmj/IO-Filter-0.01/lib/IO/Filter.pm

Also be warned that you have to have 'gzip' installed and in your path
for it to work (which if you do presumably the zlibs are available, and
you should go back to using Compress::Zlib)...

Assuming we are still here, then what you are getting in your $fio is a
blessed reference, aka an IO::Filter object, that you can then apply a
method tu, tu get your data... However what you pass to the constructor
also needs to be an opened file handle rather than the path to a file to
open, and you need to call the proper directional constructor, aka you
want to unzip rather than zip, so you end up with something like:

-- UNTESTED --

#!/usr/bin/perl
use strict;    # always
use warnings;  # usually

use IO::Filter::gunzip;

my $zipped_file = "denver.gz";
my $READHANDLE;
open($READHANDLE, $zipped_file) or die "Can't open handle on zipped
file: $!";  # you may want to set the binmode on this guy

my $fio = new IO::Filter::gunzip ($READHANDLE, "r");
$fio->print;
$fio->close;  # or close($READHANDLE);

But seriously, let us know why Compress::Zlib won't work....

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to