in reply to Re^4: help with Archive::tar
in thread help with Archive::tar

Actually, on second thought -- depending on the number of data files in your tar files, it might be quicker if you replace this line:
my ($toc) = grep { $_->name =~ m{/toc$} } $tar->get_files;
with this short-circuit loop:
my $toc = undef; for my $file ( $tar->get_files ) { if ( $file->name =~ /toc$/ ) { $toc = $file; last; } } ( defined $toc ) or do { warn "no toc file in $wdir/$tarball\n"; n +ext };
That assumes that the first time you see "toc" as the file name, this is the actual "toc" file that you want. (It also checks for the case where a tarball lacks a "toc" file.)

Replies are listed 'Best First'.
Re^6: help with Archive::tar
by paulehr (Sexton) on Apr 04, 2006 at 20:32 UTC

    Hello graff,
    I got a chance to check out the code that you posted. However when it hits line 25 I am getting a message that there was a checksum error and blows up at this point.
    Here is the output mess when i run the script:

    C:\Documents and Settings\paul.ehrenreich\Desktop>cdload.pl σÆ/╧Γ>╫▓wi←l√╔a1ÅmLú&#88 +05;‼û→â├>╔☻☺♥é§: checksum e +rror at C:\Documents and Settings\p aul.ehrenreich\Desktop\cdload.pl line 25 Invalid header block at offset unknown at C:\Documents and Settings\pa +ul.ehrenre ich\Desktop\cdload.pl line 25 ^Wæ╝↕⌡ç▄}b╕←c÷↑╣Ω +!↑ⁿ→íÑ╘w ZUu¿ W☺╞L╙DÄ +y╪⌐W∞Yß¡↓·÷┴-╥t>[├╕o& +#9612;■J│τM♂µ ╬f~└ ╓▄ñ↕♥♥⌠↓&#8 +993;ó1R↔┤u∙∟∞Lúj╔%ÿ7å: checksum e +rror at C:\Documents and Settings\pau l.ehrenreich\Desktop\cdload.pl line 25 Read error on tarfile (missing data) '0081354308-JY6097/toc' at offset + unknown a t C:\Documents and Settings\paul.ehrenreich\Desktop\cdload.pl line 25

    I am pretty much lost at this point,

      ok i am stupid (and tired) the toc file is extracted and it looks fine. It extracted to my desktop where i ran the script from.


      Everything thanks a ton for helping me out with this. I really appreciate the help and I learned something new :)