MySQL Forums
Forum List  »  Perl

Can't use an undefined value as a HASH reference
Posted by: liping yi
Date: September 01, 2010 09:54AM

Hi,
Code to get filename using unlzma:

my $input="$filePath/test.7z";
my $u = new IO::Uncompress::UnLzma $input
or die "unlzma failed: $UnLzmaError\n";

my $status;
for ($status = 1; ! $u->eof(); $status = $u->nextStream())
{
print "$u->getHeaderInfo()->{Name}\n";
my $filename = $u->getHeaderInfo()->{Name}; #line 31

while (($status = $u->read($buff)) > 0)
{
#Append/Write $buff to $filePath/$filename
open(FILE,">>$filename");
print FILE "$buff\n";
close FILE;
}

last unless $status == 0;
}

What I got:
IO::Uncompress::UnLzma=GLOB(0x84726f8)->getHeaderInfo()->{Name}
Can't use an undefined value as a HASH reference at tt.pl line 31.

My question is why it can print, but got this error?
Any help appreciated!!



Edited 1 time(s). Last edit at 09/01/2010 09:56AM by liping yi.

Options: ReplyQuote


Subject
Written By
Posted
August 31, 2010 10:39AM
Can't use an undefined value as a HASH reference
September 01, 2010 09:54AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.