Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gav (2710)

gav
  (email not shown publicly)
http://www.estey.com/
AOL IM: flufflegavin (Add Buddy, Send Message)

Hacker in NYC.

Journal of gav (2710)

Tuesday April 27, 2004
11:13 AM

Archive::Zip Tip

[ #18512 ]

If you're using Archive::Zip, one thing to remember is that if you chdir after you open the zip file, things will break if you opened the zip with an relative path. This is because Archive::Zip closes the filehandle after it has read the directory structure and then it can't re-open it to extract a file. Using File::Spec::rel2abs is the easy way to fix this.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Wow, coincidence! I just used Archive::Zip today and was much impressed by it's usefulness. I was thinking about writing a journal entry, pronouncing it the Module of the Day.

    I rarely chdir though.
  • Is to never chdir().
    • Booh.

      I think Archive::Zip should do the rel2abs() by itself — or just not close the ZIP file.

      • I agree - it shouldn't close the file.

        But in general programming terms I've come to think that any use of chdir() is probably a bad thing. Unless you have to exec a program that expects to be in a certain dir, but then you should probably fork, chdir, and exec.
        • But in general programming terms I've come to think that any use of chdir() is probably a bad thing.

          I've never considered chdir a bad thing, especially with File::chdir [cpan.org]. What's your reason for not using chdir?