gunzip module with arrays

  • Thread starter gerard.l1.demers
  • Start date
G

gerard.l1.demers

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";
 
U

Uri Guttman

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top