View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Justin Zhang > Archive-Probe-0.83 > Archive::Probe



Annotate this POD

View/Report Bugs
Module Version: 0.83   Source   Latest Release: Archive-Probe-0.86


Archive::Probe - A generic library to search file within archive


    use Archive::Probe;

    my $tmpdir = '<temp_dir>';
    my $base_dir = '<directory_of_archive_files>';
    my $probe = Archive::Probe->new();
        sub {
            my ($pattern, $file_ref) = @_;

            # do something with result files
    $probe->search($base_dir, 1);


Archive::Probe is a generic library to search file within archive.

It allows you to test the existence of a particular file, which can be described in regular expression, and optionally to extract that file and inspect the file content in custom code. It supports common archive types such as .tar, .tgz, .bz2, .rar, .zip, .7z. One archive file can contain archive file of same or other type. And level of nesting is unlimited. This module depends on unrar, 7za and tar which should be in PATH. The 7za is part of open source software 7zip. You can get it from: The unrar is freeware which can be downloaded from:


constructor new()

Creates a new Archive::Probe object.

add_pattern(regex, coderef)

Register a file pattern to search with in the archive file(s) and the callback code to handle the matched files. The callback will be passed two arguments:


This is the pattern of the matched files.


This is the array reference to the files matched the pattern. The files are extracted, hence exist, only if the second argument of the search() method evaluates to true.

search(base_dir, extract_matched)

Search registered files under 'base_dir' and invoke the callback. It requires two arguments:


This is the directory containing the archive file(s).


Extract or copy the matched files to the working directory if this parameter evaluates to true. This is useful when you need search files based on their content not just by name.


Reset the matched files list.



Set or get the working directory where the temporary files will be created.


Enable or disable the output of command line archive tool.


Archive::Probe provides plumbing boiler code to search files in nested archive files. It does the heavy lifting to extract mininal files necessary to fulfill the inquiry.


This code is in Github


Please report bugs or other issues to <>.


This module is developed by Justin Zhang <>.


Copyright (C) 2013 by Justin Zhang

This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.

syntax highlighting: