Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Extracting data from nested tgz files use Archive::Tar

by Loops (Curate)
on Nov 18, 2014 at 06:07 UTC ( #1107533=note: print w/replies, xml ) Need Help??


in reply to Extracting data from nested tgz files use Archive::Tar

Proof of concept that only works with the exact nesting and file names you specified:

use Archive::Tar; use IO::Uncompress::Gunzip; use IO::String; # Do whatever you want with each file and its data sub handle { my ($name,$data) = @_; print "file $name length ", length($data), $/; } my $filename = 'a.tgz'; my $outer = Archive::Tar->new($filename); for my $outerfile ($outer->get_files) { my $outerdata = $outer->get_content($outerfile->name); my $inner = Archive::Tar->new( IO::Uncompress::Gunzip->new( IO::String->new($outerdata))); for my $file ($inner->get_files) { next unless $file->name =~ /^.._log$/; handle $file->name, $inner->get_content($file->name); }; }

It works, but will likely be dog slow. Since your archive is only 40M maybe it doesn't matter.

Replies are listed 'Best First'.
Re^2: Extracting data from nested tgz files use Archive::Tar
by jhuijsing (Acolyte) on Nov 20, 2014 at 02:58 UTC
    No good get out of memory error.

    Back to the drawing board and use a temp directory to extract the second level tar files.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1107533]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2021-04-23 08:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?