I'm having some trouble understanding how to retrieve [\@properties] of files inside of Tarballs. This information will be later saved into a table.

Here is the information from the perldoc.

Archive::Tar->list_archive($file, $compressed, [\@properties])

Returns a list of the names of all the files in the archive. The first argument can either be the name of the tar file to list or a reference to an open file handle (e.g. a GLOB reference).

If list_archive() is passed an array reference as its third argument it returns a list of hash references containing the requested properties of each file. The following list of properties is supported: full_path, name, size, mtime (last modified date), mode, uid, gid, linkname, uname, gname, devmajor, devminor, prefix, type.

I've tried a few different test code samples but none are giving me the properties and I haven't seen any code samples online showing someone else trying to get properties.

use Archive::Tar; my @properties = "name, size, mtime"; my ($location) = "/vol/archive5/test5.tar"; my %files = Archive::Tar->list_archive($location,,[\@properties]); print Dumper \%files;
use Archive::Tar; my ($location) = "/vol/archive5/test5.tar"; my %files = Archive::Tar->list_archive($location,,['size']); foreach my $file (keys %files) { my $size = $files{$file}{'size'}; print "$size\n"; }
use Archive::Tar; my ($location) = "/vol/archive5/test5.tar"; my %files = Archive::Tar->list_archive($location,,['size']); foreach my $file (keys %files) { my $size = @{ $files{$file}{'size'} }; print "$size\n"; }

In reply to Archive::Tar->list_archive Properties by sirhalos

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.