Subject: | error while handling scalarref als logfile |
Date: | Mon, 12 Sep 2011 11:24:31 +0200 |
To: | bug-File-Unpack [...] rt.cpan.org |
From: | ToPeG <topeg [...] gmx.de> |
Hello
The module dies while using a scalarref as "logfile".
my $log;
my $up = File::Unpack->new(destdir => '.', one_shot => 1, verbose => 2, logfile => \$log);
$up->unpack( 'test.zip' );
print $log;
Message:
Use of uninitialized value $r in numeric ne (!=) at
/home/topeg/PERL/AA_LIBS/File/Unpack.pm line 394.
Use of uninitialized value $r in concatenation (.) or string at
/home/topeg/PERL/AA_LIBS/File/Unpack.pm line 394.
The error appears in the method "log". The problem is that a filehandle opend a scararref
has no systemhandle to write to. So syswrite can't work. Please use print instead.
-------------->8------------------------
sub log
{
my ($self, $text) = @_;
if (my $fp = $self->{lfp})
{
die "log($self->{logfile}): print failed: $text\n" if(!$fp->print($text));
$self->{lfp_printed}++;
}
}
-------------->8------------------------
Tobias