sirhalos has asked for the wisdom of the Perl Monks concerning the following question:
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Archive::Tar->list_archive Properties
by hdb (Monsignor) on Mar 10, 2015 at 13:33 UTC | |
|
Re: Archive::Tar->list_archive Properties
by toolic (Bishop) on Mar 10, 2015 at 13:45 UTC | |
by hdb (Monsignor) on Mar 10, 2015 at 13:50 UTC | |
by sirhalos (Sexton) on Mar 10, 2015 at 15:40 UTC | |
|
Re: Archive::Tar->list_archive Properties
by Corion (Patriarch) on Mar 10, 2015 at 13:36 UTC |