The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Archive::Any - Single interface to deal with zips and tarballs

SYNOPSIS

  use Archive::Any;

  my $archive = Archive::Any->new($archive_file);

  my @files = $archive->files;

  $archive->extract;

  my $type = $archive->type;

  $archive->is_impolite;
  $archive->is_naughty;

DESCRIPTION

This module is a single interface for manipulating different archive formats. Tarballs, zip files, etc...

Currently only tar (with or without gzip) and zip are supported.

Currently only supports unpacking.

new
  my $archive = Archive::Any->new($archive_file);
  my $archive = Archive::Any->new($archive_file, $type);

Creates an Archive::Any object representing $file, but don't do anything with it yet.

$type is optional. It lets you force the file type in-case Archive::Any can't figure it out. 'tar' or 'zip' is currently accepted.

files
  my @file = $archive->files;

Filess the file in the archive.

extract
  $archive->extract;
  $archive->extract($dir);

Extracts the files in the archive to the given directory. If no directory is given, it will go into the current working directory.

type
  my $type = $archive->type;

Returns the type of archive this is. 'zip' or 'tar'.

is_impolite
  my $is_impolite = $archive->is_impolite;

Checks to see if this archive is going to unpack into the current directory rather than create it's own.

is_naughty
  my $is_naughty = $archive->is_naughty;

Checks to see if this archive is going to unpack outside the current directory.

AUTHOR

Michael G Schwern <schwern@pobox.com>