Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > gunzip module with arrays

Thread Tools

gunzip module with arrays
Posts: n/a

I'm looking for a code snippet that works to place an unzipped
contents of a file into an array. I thought this should work but get
the following from the code:

$ ./
original: SCALAR(0x6055d30)
Reference_example ARRAY(0x5eaac90)
Array_example toast fruit cereal

# Code snippet
# gunzip example into an array reference
gunzip $input => \@outPut
or die "gunzip failed: $GunzipError\n";

my @outPutArray = @$outPut;

foreach $outRec (@outPutArray) {

print "Referenced: $outPut\n";
print "Dereferenced: @$outPutArray\n";
print "original: @outPut\n";

# Example of array reference that seems to work
my $array1_ref = ['toast', 'fruit', 'cereal'];
my @array = @$array1_ref;

print "Reference_example $array1_ref\n";
print "Array_example @array\n";
Reply With Quote
Uri Guttman
Posts: n/a
>>>>> "gldc" == gerard l1 demers@verizon com <(E-Mail Removed)> writes:

gldc> gunzip $input => \@outPut
gldc> or die "gunzip failed: $GunzipError\n";

gldc> my @outPutArray = @$outPut;

@outPut is not the same as $outPut.

the former is an array which (supposedly) has the data, the latter is an
unrelated scalar with the same name and is empty. if you had run this
with strict and warnings you would have learned this.


Uri Guttman ------ Removed) -------- --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- ---------
--------- Gourmet Hot Cocoa Mix ---- ---------
Reply With Quote

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
How to "gunzip-iterate" over a file? kj Python 3 07-30-2009 12:02 PM
Gzip - gunzip using zlib flebber Python 2 06-09-2007 05:46 PM
zlib.decompress cannot, gunzip can Python 2 03-01-2005 08:31 AM
Re: how to gunzip a string ? Bill Loren Python 0 07-31-2003 09:11 AM
Re: how to gunzip a string ? Andreas Kuntzagk Python 0 07-31-2003 08:33 AM