File::Raw · File::Raw::Archive 0.04
File::Raw::Archive
Tar archives, read and written as a stream.
Tarballs entry by entry, never the whole archive in memory: iterate, list, extract, or build one. ustar, GNU long names and PAX headers, and .tar.gz with compression => 'gzip'. Its own plugin header lets other container formats load beside tar.
use File::Raw::Archive;
File::Raw::Archive->each('logs.tar.gz', compression => 'gzip', sub {
my $e = shift;
return if $e->is_dir;
printf "%s (%d bytes)\n", $e->name, $e->size;
});
my $w = File::Raw::Archive->create('out.tar.gz', compression => 'gzip');
$w->add(name => 'README', content => "hello\n", mode => 0644);
$w->close;
What you get
-
Read tar as a stream
An entry at a time with
openandnext, a callback witheach, or everything as metadata withlist. -
Every tar dialect
ustar, GNU
././@LongLinklong names and PAX extended headers on read. ustar, GNU, PAX or automatic on write. -
Extract
extract_allto a directory, orextractone entry by name. -
Build one
create, thenaddfiles and directories with their content and mode, gzip-compressed at the level you choose. -
More formats by plugin
Archive publishes its own plugin header, so other container formats load beside tar as sister modules.
The numbers
Against the fastest alternative that was installed, and shown whichever way it went.
- 16.4x list a 100-file tar, against Archive::Tar File::Raw::Archive 0.04 at 6100/s, Archive::Tar 3.04 at 371/s
- 3.0x extract a 100-file tar, against Archive::Tar File::Raw::Archive 0.04 at 208/s, Archive::Tar 3.04 at 69.3/s
Measured on Apple M5, darwin with perl 5.42.0, 2026-10-19: each entry timed for 3 CPU seconds by the Benchmark module, 3 times, the median kept, after checking that both sides produced the same result. Every number.
For C
archive_plugin.h is a second level of plugin: a container format registers itself beside the built-in tar, and File::Raw::Archive finds it by name or by probing the file.
The reference
- File::Raw::Archive Archive container reader/writer
- File::Raw::Archive::Entry Single archive entry (metadata + lazy content)
- File::Raw::Archive::Reader Sequential archive iterator
- File::Raw::Archive::Writer Archive entry emitter