Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Untaring with perl

by gryphon (Abbot)
on Aug 24, 2005 at 17:30 UTC ( #486305=note: print w/ replies, xml ) Need Help??


in reply to Untaring with perl

Greetings mrbbq,

This is untested, and I only just now tossed it together, but is this what you're asking for?

use Archive::Tar; my $tar = Archive::Tar->new; chdir '/tmp' or die $!; $tar->read('anything.tgz', 1, { 'extract' => 1 } );

I'd rather not have to chdir; instead, I'd like to tell Archive::Tar where to extract the files. How to do that is probably in the POD somewhere.

gryphon
Whitepages.com Development Manager (DSMS)
code('Perl') || die;


Comment on Re: Untaring with perl
Download Code
Re^2: Untaring with perl
by mrbbq (Sexton) on Aug 24, 2005 at 18:08 UTC
    Works perfect, thank you.
Re^2: Untaring with perl
by mrbbq (Sexton) on Aug 24, 2005 at 18:19 UTC
    could anything.tgz be a variable?
    $tar->read('$tar_file",1, { 'extract' => 1 });
    I could not get it to work passing a variable...ideas?
    thanks

      Greetings mrbbq,

      You have a single-quote just before $tar_file that doesn't match the double-quote at the end. You should either change the single to a double, or (and better) just drop the quotes.

      use strict; my $tar_file = 'anything.tgz'; $tar->read( $tar_file, 1, { 'extract' => 1 } );

      gryphon
      Whitepages.com Development Manager (DSMS)
      code('Perl') || die;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2015-07-04 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls