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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |