My thanks to all who provided help and assistance with this. I now have a working test solution which I present below as this may be useful for others.

I used Path::Tiny, as originally shown by ++tybalt89, to generate the list of files for archiving. I needed to tweak the suggested code in a few places, as follows:

Here's the test script. Note that the directory structure under $src_dir is exactly the same as that presented in the OP.

#!/usr/bin/env perl use 5.016; use warnings; use Archive::Tar; use Cwd; use Path::Tiny; my $src_dir = '/Users/ken/tmp/test_arch/src'; my $zip_dir = '/Users/ken/tmp/test_arch/zip'; my $top_dir = 'fred'; my $zip_name = 'fred.tar.gz'; my $zip_path = path($zip_dir, $zip_name); { use autodie; my $cur_dir = getcwd; chdir $src_dir or die; my @tar_files = ($top_dir); path($top_dir)->visit( sub { push @tar_files, "$_" }, { recurse => 1 } ); my $tar = Archive::Tar::->new(); $tar->add_files(@tar_files); $tar->write($zip_path, COMPRESS_GZIP); chdir $cur_dir or die; }

A sample run, as well as various checks, are in the spoiler:

— Ken


In reply to Re: Creating a tarball [SOLUTION] by kcott
in thread Creating a tarball by kcott

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.