Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Archive::Zip Compaitibility Issues??

by Commy_Code_Monkey (Acolyte)
on Dec 15, 2008 at 15:40 UTC ( [id://730432]=perlquestion: print w/replies, xml ) Need Help??

Commy_Code_Monkey has asked for the wisdom of the Perl Monks concerning the following question:

I have a problem. My script (In TK ActivePerl 10 on WinXP), creates several files in the working directory. It runs fine and performs all it's functions correctly. What I wanted to do, was then collect all the files and zip them. I found Archive::Zip to be the tool to use, but when I add the line use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); my script becomes a useless black box. When I execute it, nothing happens. Perl.exe opens, and then immediately closes, with no error message, and no indication of why. When I remove the 'use' statement, it works fine again. Am I missing something?

Replies are listed 'Best First'.
Re: Archive::Zip Compaitibility Issues??
by svenXY (Deacon) on Dec 15, 2008 at 15:45 UTC
    Hi,
    what happens if you click Start->Run->type 'cmd'->type 'perl -MArchive::Zip -e1'? Meaning: is Archive::Zip properly installed?
    Regards,
    svenXY
      Hey thanks for the promt reply, typing 'perl -MArchive::Zip -e1' in the command prompt does nothing
      C:\>perl -MArchive::Zip -el C:\>
      No error, no anything. I'm using the GUI PPM to install packages, and it has installed correctly for every other module i've ever installed.
        So you have the module Archive:Zip... though perhaps your module is too old. You should try to load it with the tags to import. On the command line, try
        perl -MArchive::Zip=:ERROR_CODES,:CONSTANTS -e1
        or just one of them, if it fails with both.

        If that doesn't work, try upgrading the module. You could ask for the current version first:

        perl -MArchive::Zip -le "print $Archive::Zip::VERSION"
        (Windows quotes)

        and check on CPAN if that version supports these tags, to see if that would likely fix it.

        Hi,
        it was 'e1' (1 like the number one, not like L), but anyway - that at least shows that the module is indeed installed properly as otherwise it would have had complained loudly.

        Now I'd go and test some of the basic code supplied in Archive::Zip in a non-TK (a.k.a. known as command line) script on your box and verify that whatever you try to achieve works there. After that, put it back into your Tk-script and proceed. Aah - and don't forget to use strictures!

        Regards,
        svenXY

        I looked up the module on CPAN, and according to the dependencies list it should install. Try downloading from CPAN. I do use Archive::Zip on my XP box running AS 5.10 and it works great. I grab all my modules from CPAN though.

        The only other thing I can come up with is that you may have Cygwin in your path causing issues?

Re: Archive::Zip Compaitibility Issues??
by Anonymous Monk on Dec 15, 2008 at 16:10 UTC
    Maybe confict between exports, do you have strict/warnings turned on ?
      Ok, I've tried all the suggestions up to this point. Upgraded where possible, tried to do a simple non gui script (has the same problem), and have turned trict and warnings on and off with no change. Perhaps it is time to set my desk on fire?
      use Archive::Zip; use strict; use warnings; my $zip=Archive::Zip->New(); my @filestozip=('RED_b0.apf','RED_b1.apf','RED_b2.apf','RED_b3.apf'); my $filelist=$zip->addFile(@filestozip); $zip->writeToFileNamed('testthis.zip');
        my $filelist=$zip->addFile(@filestozip);

        Two things to note here: (1) addFile() does not take a list of files, (2) it returns undef "if the name given does not represent a readable plain file or symbolic link".  I'm not entirely sure whether that's the issue in your case, but at least, it's worth checking the return value...

        I cut and pasted this and got the following error: Can't locate object method "New" via package "Archive::Zip" at use_test.pl line 7.
Re: Archive::Zip Compaitibility Issues??
by almut (Canon) on Dec 15, 2008 at 21:39 UTC

    What output do you get if you enable debugging via the following two environment variables?

    (1) for DynaLoader (loading of XS modules, shared libs):

    > set PERL_DL_DEBUG=1 > perl zipper.pl

    (2) for execution tracing:

    > set PERLDB_OPTS="AutoTrace NonStop" > perl -ds zipper.pl

    How far does the latter get? Does it terminate permaturely, i.e. what are the last lines executed?

    (See perldebug for other options you might want to set with PERLDB_OPTS, e.g. frame=...)

Re: Archive::Zip Compaitibility Issues??
by scorpio17 (Canon) on Dec 16, 2008 at 19:04 UTC
    Archive::Zip depends on Compress::Zlib, which is itself a wrapper around the Zlib library. So, I'd suggest checking that you have the latest versions of both of those.
Re: Archive::Zip Compaitibility Issues??
by Rudif (Hermit) on Dec 17, 2008 at 22:12 UTC
    Hello Commy_Code_Monkey

    I have a command line script named ziprecent.pl, reproduced below. It uses Archive::Zip and a few other modules, all part of Active State Perl, or available via ppm.

    It works nicely for me with 5.10 as it did for 5.8 and with earlier Perl builds.
    Does it work for you ?
    If yes, perhaps you will find out what you are doing differently, by comparing your script with mine.
    If not, perhaps there is a problem with your perl installation.

    HTH

    Rudif

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://730432]
Approved by svenXY
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-25 16:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found