Skip Menu | will be shut down on March 1st, 2021.

This queue is for tickets about the IO-Compress CPAN distribution.

Report information
The Basics
Id: 67554
Status: resolved
Priority: 0/
Queue: IO-Compress

Owner: Nobody in particular
Requestors: fuzz [...]

Bug Information
Severity: (no value)
Broken in: 2.030
Fixed in: 2.034

Subject: Behavior of eof with empty files is different from the normal IO::File->eof()
Download (untitled) / with headers
text/plain 876b
I've noticed a slightly little difference between the handling of empty files from IO::File and IO::Uncompress::(Gunzip||Bunzip2). Empty files don't return a eof at once after opening an empty file. Here's some pseudocode: touch empty ; gzip empty $handle = IO::Uncompress::Gunzip->new( 'empty.gz '); print $handle->eof(); # prints 0, should be 1 print $handle->getline(); # prints empty string, should be undef Here's the behavior with IO::File: touch empty $handle = IO::File->new( 'empty'); print $handle->eof(); # prints true print $handle->getline(); # produces undefined warning I've attached a sample script that will print the above values. Here the mini usage for this script: 1) touch empty ; gzip empty ; touch empty 2) perl empty ; perl empty.gz Then you will notice the difference in the output. Thanks for your work.
text/x-perl 795b
#!/usr/bin/perl use strict; use warnings; use IO::Uncompress::Gunzip; use IO::Uncompress::Bunzip2; use IO::File; my $filename = shift || die; my $line; my $handle; if ($filename =~ /.gz$/ ) { $handle = IO::Uncompress::Gunzip->new( $filename ); } elsif ($filename =~ /.bz2$/ ) { $handle = IO::Uncompress::Bunzip2->new( $filename ); } else { $handle = IO::File->new( $filename ) } printf "eof .... : %s\n", $handle->eof() ? 1 : 0; print "\n"; print "reading...\n\n"; $line = <$handle>; printf "eof .... : %s\n", $handle->eof() ? 1 : 0; printf "line ... : %s\n", defined $line ? 'defined' : 'undefined'; print "\n"; print "reading...\n\n"; $line = <$handle>; printf "eof .... : %s\n", $handle->eof() ? 1 : 0; printf "line ... : %s\n", defined $line ? 'defined' : 'undefined';
Download (untitled) / with headers
text/plain 143b
Hi Erik, thanks for the bug report. even better you provided a script to trigger the bug. I've reproduced it here. Working on a fix now. Paul

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to