Subject: | have Compress::Zlib use normal filehandles and functions |
Date: | Wed, 08 Dec 2010 14:44:23 -0800 |
To: | bug-Compress-Zlib [...] rt.cpan.org |
From: | Matt Taggart <matt [...] lackof.org> |
I have a feature request for the Compress::Zlib module. Hopefully it's a
good one but if my lack of perl guruness means I am just not using it
right, feel free to let me know :)
I wanted to add support to an existing perl script to have it be able to
open gzipped files as well as normal files. The script already used a
FILEHANDLE and did things like seek(FILEHANDLE, $startpos, 0) and while
(<FILEHANDLE>). I wanted to be able to just check if the file ended in .gz
and then if it did open it in a special way but not have to modify the rest
of the script. At first I tried this
open(FILEHANDLE, "-|", "zcat", $filename);
seek(FILEHANDLE, $startpos, 0);
but the latter failed, I guess seek doesn't work well on pipes?
So then I started to look at using Compress::Zlib, but that meant having to
use gzopen, gzseek, gzreadline, etc.
Could Compress:Zlib somehow use normal filehandles? You'd still have to do
a special open, but after that it would be nice to use normal methods.
Maybe the close would need to be special too (or maybe that could be
smart?).
(I don't think it matters but I am using perl 5.10.0 and debian's
libio-compress-zlib-perl version 2.012-1)
Thanks,
--
Matt Taggart
matt@lackof.org