prescott2006 has asked for the wisdom of the Perl Monks concerning the following question:
In the doc page (http://perldoc.perl.org/IO/Uncompress/Bunzip2.html#OO-Interface), it is stated that \$buffer in the sample code can be an array reference. So I try to write like this:use strict ; use warnings ; use IO::Uncompress::Bunzip2 qw(bunzip2 $Bunzip2Error) ; use IO::File ; my $input = new IO::File "<file1.txt.bz2" or die "Cannot open 'fil +e1.txt.bz2': $!\n" ; my $buffer ; bunzip2 $input => \$buffer or die "bunzip2 failed: $Bunzip2Error\n +";
But what I get is "Can't use an undefined value as an array reference..." and print out SCALAR {0x266a6ac}. Anybody can help me?use strict ; use warnings ; use IO::Uncompress::Bunzip2 qw(bunzip2 $Bunzip2Error) ; use IO::File ; my $input = new IO::File "<file1.txt.bz2" or die "Cannot open 'fil +e1.txt.bz2': $!\n" ; my $buffer = \@apple ; bunzip2 $input => $buffer or die "bunzip2 failed: $Bunzip2Error\n" +; print @{$buffer}; foreach (@{$buffer}) { # do something }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Read bzip2 directly into array
by Happy-the-monk (Canon) on Apr 03, 2012 at 09:03 UTC | |
by prescott2006 (Acolyte) on Apr 03, 2012 at 11:22 UTC | |
by Happy-the-monk (Canon) on Apr 03, 2012 at 11:45 UTC | |
|
Re: Read bzip2 directly into array
by baxy77bax (Deacon) on Apr 03, 2012 at 08:25 UTC | |
by prescott2006 (Acolyte) on Apr 03, 2012 at 08:35 UTC | |
by baxy77bax (Deacon) on Apr 03, 2012 at 09:05 UTC | |
by prescott2006 (Acolyte) on Apr 03, 2012 at 11:05 UTC | |
by Happy-the-monk (Canon) on Apr 03, 2012 at 12:03 UTC |