|Keep It Simple, Stupid|
Creating a tarballby kcott (Chancellor)
|on Feb 07, 2019 at 03:08 UTC||Need Help??|
kcott has asked for the
wisdom of the Perl Monks concerning the following question:
Given a directory structure which looks something like this (which I've been using for testing):
I'm looking for a way to implement the following command in Perl:
I thought the builtin Archive::Tar module was possibly the way to go. I can get this to achieve what I want but it's horribly clunky:
This has additional problems in that the directory structure could be deeper and hidden files (starting with '.') are not captured by any of those glob patterns.
I tried using "fred" and "fred/" as the sole arguments to add_files() but they only pick up the top-level directory, not the rest of the directory structure. I can't see an add_directory() (or similarly named) method. I also tried with the create_archive() class method but had a similar lack of success.
I've also had a hunt around various core and CPAN modules in the Archive:: and IO:: namespaces: none seemed to do what I want.
I could write a recursive routine to capture the entire directory into an array (for add_files(@filenamelist)). That would be my fallback plan but I was hoping there might be a more elegant (less code) way of doing this.
Any ideas on how I might achieve what I want with either Archive::Tar, or some other module, would be appreciated.