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. Advertisements

  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. Advertisements

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. Replies:
    2
    Views:
    1,474
  2. flebber

    Gzip - gunzip using zlib

    flebber, Jun 9, 2007, in forum: Python
    Replies:
    2
    Views:
    546
    Stefan Behnel
    Jun 9, 2007
  3. Philipp
    Replies:
    21
    Views:
    1,534
    Philipp
    Jan 20, 2009
  4. kj
    Replies:
    3
    Views:
    1,216
  5. Istvan Gouritz
    Replies:
    0
    Views:
    322
    Istvan Gouritz
    Oct 11, 2010
  6. arun
    Replies:
    4
    Views:
    594
  7. Markus Dehmann

    gunzip stdin stream?

    Markus Dehmann, Jan 21, 2006, in forum: Perl Misc
    Replies:
    7
    Views:
    515
  8. none

    gunzip while downloading via ftp

    none, Feb 19, 2006, in forum: Perl Misc
    Replies:
    17
    Views:
    406
Loading...