For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2005 > IO::Scalar and Archive::Zip









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author IO::Scalar and Archive::Zip
Gerhard Meier

2005-07-24, 8:29 pm

Hi,

I want to fetch a zip file from the net with LWP::UserAgent and
then use Archive::Zip to manipulate it. But I don't want to store
the zip file on the disk (if possible). This is where IO::Scalar
came in. But it seems that Archive::Zip doesn't work together
with IO::Scalar. Here is a litte sample code, that demonstrates
the problem:

#!/usr/bin/perl

use Archive::Zip;
use IO::Scalar;
use strict;

my $zip="test.zip";

open(my $fh, $zip) or die($!);
my $zipstring=do{local $/; <$fh>};
close($fh);

#tie *ZIP, 'IO::Scalar', \$zipstring;
my $scalarfh = new IO::Scalar \$zipstring;
my $archive = Archive::Zip->new();
$archive->readFromFileHandle($scalarfh, "foobar?.zip");
__END__

[0]> perl test.pl
error: file not sable
at /usr/local/lib/perl5/site_perl/5.8.7/Archive/Zip.pm line 961
Archive::Zip::Archive::readFromFileHandl
e('Archive::Zip::Archive=HASH(0x82caf1c)
',
'IO::Scalar=GLOB(0x823cb38)', 'test.zip') called at test.pl line
17

This is the error I've got. The IO::Scalar manpage says that
IO::Scalar filehandles are sable. Somebody knows any
workaround?

perl -V is attached.

[0]> perl -MArchive::Zip -MIO::Scalar -le 'print $Archive::Zip::VERSION,"\n",$IO::Scalar::VERSION'
1.16
2.110

/GM

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com