Extracting your archives

I'm on a bit of a roll about unpacking archives. Last week I wrote about peeking into archives and recently I was wondering about extracting archives.

The classic tool for extracting archives is Archive::Extract. This module was originally written for CPANPLUS and has been in the Perl core since 5.10.0. It tries a variety of methods for extracting archives, from pure-Perl modules such as Archive::Zip and Archive::Tar (portable but slow) to external tar and unzip commands (unportable but slightly faster).

Having played around with libarchive, a "C library and command-line tools for reading and writing tar, cpio, zip, ISO, and other archive formats", I wondered if it would be interesting to use it instead.

Behold my newly-written module Archive::Extract::Libarchive. This uses libarchive to extract archives, extracts most archive formats and is quite fast. It requires libarchive to be installed.

How fast? Well, it depends on what you are extracting. If you happen to be extracting all the current CPAN distributions (for a total of 7.1G), then Archive::Extract (with PREFER_BIN) takes about 20 minutes while Archive::Extract::Libarchive takes about two minutes.

Yet another tool for your archive extracting toolbox...

1 Comment

it would probably make sense to have Archive::Extract call Archive::Extract::Libarchive under the hood if it's already installed since Archive::Extract is used in so many places.

Leave a comment

About acme

user-pic Léon Brocard (aka acme) is an orange-loving Perl eurohacker with many varied contributions to the Perl community, including the GraphViz module on the CPAN. YAPC::Europe was all his fault. He is still looking for a Perl Monger group he can start which begins with the letter 'D'.