Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

gunzip module with arrays

 
 
gerard.l1.demers@verizon.com
Guest
Posts: n/a
 
      06-03-2009

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:

$ ./testsplit2a.pl
Referenced:
Dereferenced:
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($outRec);
}

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
Guest
Posts: n/a
 
      06-03-2009
>>>>> "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

--
Uri Guttman ------ http://www.velocityreviews.com/forums/(E-Mail Removed) -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
 
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
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 enrio@online.no 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



Advertisments