Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Uncompressing winzip downloaded in memory

by Athanasius (Archbishop)
on Feb 04, 2015 at 04:09 UTC ( [id://1115475]=note: print w/replies, xml ) Need Help??


in reply to Uncompressing winzip downloaded in memory

Hello ganeshPerlStarter,

The IO::Uncompress::Unzip::unzip function also accepts a reference to a string for the input:

#! perl use strict; use warnings; use IO::Uncompress::Unzip qw(unzip $UnzipError) ; my $file = 'data.zip'; open(my $fh, '<', $file) or die "Cannot open file '$file' for reading: $!"; binmode $fh; my $input; { local $/ = undef; $input = <$fh>; } close $fh or die "Cannot close file '$file': $!"; my $output; my $status = unzip \$input => \$output or die "Unzip failed: $UnzipError\n"; print "Status: $status\n"; print "Unzipped text:\n\n>>>$output<<<\n";

I created a text file named “data.txt” and zipped it to “data.zip” using 7-Zip. The above script reads the zipped file data into the scalar $input, then correctly unzips it when passed a reference to the scalar (string) — \$input — as the input parameter.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: Uncompressing winzip downloaded in memory
by ganeshPerlStarter (Novice) on Feb 04, 2015 at 05:59 UTC
    Hi, Yes this helps. Thanks for quick resolution Best Regards

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1115475]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-16 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found