in reply to Re^2: help with Archive::tar
in thread help with Archive::tar
That means this particular tar ball contains a directory called "81334567-COMPLETE", and the file you want to extract is inside that directory. You need to pass "81334567-COMPLETE/toc" as first arg in the "extract_file" call.
To do that in a programmatic way -- without having to hard-code the directory name for each tar file -- you could try something like this:
#!/usr/bin/perl use strict; use Archive::Tar; my $wdir = "U:/EMM loads"; # load an array of tar file names: open( DIR, $wdir ) or die "$wdir: $!"; my @tarballs = grep /\.tar$/, readdir DIR; closedir DIR; # for each tar file, yank out the "toc" file: for my $tarball ( @tarballs ) { my $tar = Archive::Tar->new( "$wdir/$tarball" ); my ($toc) = grep { $_->name =~ m{/toc$} } $tar->get_files; # make up a local name for this toc file, based on the tarball name: ( my $tocname = $tarball ) =~ s/tar$/toc/; # write the toc file data to the local toc file: open( TOC, ">", $tocname ) or die "$tocname: $!"; print TOC $toc->get_content; close TOC; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: help with Archive::tar
by paulehr (Sexton) on Apr 03, 2006 at 12:20 UTC | |
by graff (Chancellor) on Apr 03, 2006 at 15:21 UTC | |
by paulehr (Sexton) on Apr 04, 2006 at 20:32 UTC | |
by paulehr (Sexton) on Apr 04, 2006 at 22:05 UTC |