gunzip module with arrays

Discussion in 'Perl Misc' started by gerard.l1.demers@verizon.com, Jun 3, 2009.

  1. Guest

    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";
    , Jun 3, 2009
    #1
    1. Advertising

  2. Uri Guttman Guest

    >>>>> "gldc" == gerard l1 demers@verizon com <> 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.sysarch.com --
    ----- Perl Code Review , Architecture, Development, Training, Support ------
    --------- Free Perl Training --- http://perlhunter.com/college.html ---------
    --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
    Uri Guttman, Jun 3, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Kuntzagk

    Re: how to gunzip a string ?

    Andreas Kuntzagk, Jul 31, 2003, in forum: Python
    Replies:
    0
    Views:
    437
    Andreas Kuntzagk
    Jul 31, 2003
  2. Bill Loren

    Re: how to gunzip a string ?

    Bill Loren, Jul 31, 2003, in forum: Python
    Replies:
    0
    Views:
    1,061
    Bill Loren
    Jul 31, 2003
  3. Replies:
    2
    Views:
    1,219
  4. flebber

    Gzip - gunzip using zlib

    flebber, Jun 9, 2007, in forum: Python
    Replies:
    2
    Views:
    331
    Stefan Behnel
    Jun 9, 2007
  5. kj
    Replies:
    3
    Views:
    730
Loading...

Share This Page