Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How do I read a GZipped UTF-8 file from Perl on Windows?

Reply
Thread Tools

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

 
 
DmitryB
Guest
Posts: n/a
 
      05-29-2007
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?

Thanks.

 
Reply With Quote
 
 
 
 
DmitryB
Guest
Posts: n/a
 
      06-01-2007
On May 29, 1:24 pm, DmitryB <(E-Mail Removed)> wrote:
> 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?
>
> Thanks.


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

 
Reply With Quote
 
 
 
 
Michele Dondi
Guest
Posts: n/a
 
      06-01-2007
On Fri, 01 Jun 2007 05:47:13 -0000, DmitryB <(E-Mail Removed)>
wrote:

>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.


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Making File.open work on gzipped files Martin Hansen Ruby 14 08-18-2010 07:08 PM
How to read gzipped utf8 file in Python? John Nagle Python 1 11-22-2007 08:25 PM
Can sqlite read gzipped databases? Paul Smith Python 1 03-21-2007 05:00 AM
trouble reading a gzipped xml-file Guido de Melo Ruby 4 11-14-2005 04:07 PM



Advertisments