Subject: | gzopen doesn't work on IO::String filehandles |
Running Compress-Zlib-1.19 via IO::Zlib-1.02 under perl 5.8.0-darwin (OSX).
This code snippet fails with the error message:
gzopen: file parameter is not a filehandle or filename at show.pl line 6
------------ show.pl -----------
use IO::String;
use Compress::Zlib;
my $buf = "testing";
my $fh = IO::String->new($buf);
my $gz_fh = gzopen($fh, "r");
------------ show.pl -----------
The problem is that gzopen needs filehandles to be GLOBs but IO::String objects are not GLOBs at their core. Additionally, IO::Strings return undef from fileno(), so this is clearly a deeper problem... Perhaps gzopen could test against (can("fileno") && defined fileno()) instead of the GLOB test.
I realize that I could use Compress::Zlib::memGzip to do what the example above is trying to do, but I have a more complex case where I create the IO handle at a high level and pass it back to a much deeper routine that wants to add a gzip layer. My app needs to be 5.6.0-compatible, so PerlIO::gzip is not an option here, I think.