Archiv...Create(3pm)
β¨ NAME β¨
Archive::Any::Create β the abstract API bestie that makes archives for you π (tar.gz AND zip, we contain multitudes)
πΈ SYNOPSIS πΈ
okay so here's the whole vibe in one code block, no cap:
use Archive::Any::Create;
my $archive = Archive::Any::Create->new;
$archive->container('foo'); # top-level directory
$archive->add_file('bar.txt', $data); # foo/bar.txt
$archive->add_file('bar/baz.txt', $data); # foo/bar/baz.txt
$archive->write_file('foo.tar.gz');
$archive->write_file('foo.zip');
$archive->write_filehandle(\*STDOUT, 'tar.gz');
likeβ¦ look at that. one object, so many archive formats, zero drama π
π¦ DESCRIPTION π¦
Archive::Any::Create is a wrapper module, and its whole personality is "make tar / tar.gz / zip files with a single easy-to-use API." ONE API. that's it. that's the girl. she does not make you learn three different modules, she just handles it. iconic behaviour, honestly π
π METHODS π
π new
Create new Archive::Any::Create object. No parameters. that's right bestie, no arguments, no config, no nothing β just vibes and a fresh object π
π container($dir)
Specify a top-level directory (or folder) to contain multiple files.
it's not *necessary*β¦ but it is recommended, because it makes a good-manner archive file. so like, be a good-manner archive file. do it for her π«Ά
π add_file($file, $data)
Add a file that contains $data as its content. and $file? $file can be a file in the nested subdirectory. yes girl, go deep, the nesting is encouraged π§
π write_file($filename)
Write an archive file named $filename.
This method is DWIMmy β and by DWIMmy I mean it automatically dispatches the archiving module based on its filename. so it justβ¦ knows. mind-reading queen π₯
So:
$archive->write_file("foo.tar.gz")will create a tarball$archive->write_file("foo.zip")will create a zip file with the same contents
same contents, different container, she ate π
π write_filehandle($fh, $format)
Write an archive data stream into a filehandle. $format is either, tar, tar.gz or zip. pick your fighter, stream it straight out, no filesystem required π
π AUTHOR π
Tatsuhiko Miyagawa <miyagawa@bulknews.net>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
(shoutout to the author, absolute legend, we stan π)
π₯ SEE ALSO π₯
Archive::AnyArchive::TarArchive::Zip
go read those too, iykyk π
perl v5.34.0 Β· 2022-06-08 Β· and that's the whole page bestie, thanks for coming to my ted talk, go forth and archive responsibly πβ¨ππ¦πΈπ π«Ά
π¦ where this page comes from
- debian bookworm: libarchive-any-create-perl 0.3-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libarchive-any-create-perl 0.3-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libarchive-any-create-perl 0.3-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libarchive-any-create-perl 0.3-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libarchive-any-create-perl 0.3-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms