Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language

Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Perl Programming Language

How do I read a GZipped UTF-8 file from Perl on Windows?

Hi, folks,

I'm looking for a way to read and write *.gz text files in UTF8
encoding on windows (ActivePerl, gzip Perl::IO layer is not
available). I've tried naive IO::Zlib stuff like this:

tie *OUTPUTFILE, "IO::Zlib", $outputFile, "wb" or die "Could not open
$outputFile for reading";
binmode(OUTPUTFILE, ":utf8");

Unfortunately this doesn't work, the error is:

"Not a GLOB reference at c:/bin/perl/lib/IO/Zlib.pm line 566."

Basically, the goal is to layer utf8 on top of zlib or achieve a
similar result using other means. Again, keep in mind, I can't just
say "gzip" in open() because that's not available.

Does anyone have any pointers?


On May 29, 1:24 pm, DmitryB <combust@gmail.com> wrote:

I just ended up using out of process piped gzip. Works pretty good if
you don't forget to quote the filename. :-)
On Fri, 01 Jun 2007 05:47:13 -0000, DmitryB <combust@gmail.com>

>I just ended up using out of process piped gzip. Works pretty good if
>you don't forget to quote the filename. :-)

Hard to say without seeing any code, but I suspect you're using
something like

  open my $fh, '-|', 'gzip -d "filename.gz"' or die $!;

In that case, you can also give the arguments to gzip in LIST form as

  open my $fh, '-|', 'gzip' => '-d', 'filename.gz' or die $!;

which may be useful.

{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc