in reply to Archive::Tar from somewhere outside my runtime directory

You should read the documentation describing using $tar->setcwd( $cwd ); at the end of the object methods section in the Archive::Tar docs. In part it says:

Archive::Tar needs to know the current directory, and it will run Cwd::cwd() every time it extracts a relative entry ...
True laziness is hard work

Replies are listed 'Best First'.
Re^2: Archive::Tar from somewhere outside my runtime directory
by murrayn (Sexton) on Dec 12, 2011 at 06:23 UTC
    This is where my inexperience shows!
    $tar->setcwd($vsvroot); foreach my $vsvxdb (<cntl/*>) { $tar->add_files($vsvxdb); } $tar->write("$vsvroot/tmp/cntlbkup.tar");
    I thought from my reading of the doc that my $tar->setcwd would have caused tar to find all files in the $vsvroot/cntl directory then archive them in $vsvroot/tmp/cntlbkup.tar. I know those files exist but I don't get anything in the archive although the write statement does create it.

      Nope. Reading the docs it looks like setcwd is pure optimisation and that the cwd has to be set for relative paths to do what you expect. However there is an implication that absolute paths are unaffected by such silliness. So, you have two options ...

      True laziness is hard work
        It's working now - needs the chdir function, not tar->cwd!
        chdir($vsvroot); foreach my $vsvxdb (<cntl/*>) { $tar->add_files($vsvxdb); } $tar->write("$vsvroot/tmp/cntlbkup.tar");
        I think that the doc is actually telling me that tar->cwd is relevant only for extraction, not for creation.