in reply to Better way to use File::Find and Archive::Tar

The easiest way to get the relative paths might be to chdir to the appropriate directory (i.e. /long/full/path/to/) and then call find with an argument of '.'. When you call add_files, you'll automatically be passing in a relative path.
  • Comment on Re: Better way to use File::Find and Archive::Tar

Replies are listed 'Best First'.
Re: Re: Better way to use File::Find and Archive::Tar
by brendonc (Novice) on Mar 17, 2001 at 01:04 UTC
    Yes, I thought this too. But, the tar file gets created wrong. It looks like this:
    ./web_dir ./cgi-bin ./www ./etc
    Here's what I changed in my code:
    ... chdir("$web_base/$web_to_del"); find(\&archive, "."); ...
    When I un-tar it, all of the the files and directories underneath the web_dir are created separately instead of getting created under the web_dir.

    Now if I just change into the directory directly above it, the tar file is created with just the web_dir and no other files or directories below it. Code:

    ... chdir("$web_base"); find(\&archive, "$web_to_del"); ...
    I've tried a couple of other variations than this as well, but I get comparable (wrong) results.