rkg has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I am having trouble w/ IO::Zlib on WinXP ActiveState 5.8. The following code spits out a few hundred bytes, garbled, then terminates early (no error). The .gz file is known to be uncorrupted -- and I can extract it successfully with WinZip etc. Is this a binmode issue? If so, how do I set binary mode on the filehandle? Or, what? Thanks!

rkg

use strict; $|++; use IO::Zlib; use Data::Dumper; my $fname = 'xxxxx-access_log.7.gz'; my $fhin = IO::Zlib->new($fname, 'rB') or die $!; die "bad file handle" unless $fhin->can('getline'); while (defined(my $line = $fhin->getline())) { print "$line\n"; }

Replies are listed 'Best First'.
Re: WinXP & IO::Zlib: binmode issues? or...?
by PodMaster (Abbot) on Aug 25, 2003 at 17:31 UTC
    Hmm what you have does not display my entire file either, but the following works perfectly:
    use IO::Zlib; tie *FILE, 'IO::Zlib', "xxxxx-access_log.7.gz", "rb"; print <FILE>; __END__ I wish I were an oscar meyer weiner yeah!
    as does
    use IO::Zlib; my $fh = new IO::Zlib; if ($fh->open("xxxxx-access_log.7.gz", "rb")) { print <$fh>; $fh->close; } __END__
    soooo, I can't tell you what's wrong, but hey ;)

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.