brendonc has asked for the wisdom of the Perl Monks concerning the following question:
I am creating a small helper script to create/delete webs. I decided I wanted to have the script archive all of the files in the web directory and place the tar file in a defunct directory. After searching around on CPAN and the like, I decided to use File::Find to traverse the directory for all files, and Archive::Tar to archive/compress the files. Here is what I have now:
This code works, but, I have two issues with this: I get this warning:sub del_web() { ... my($tar) = Archive::Tar->new(); $tar->read("$web_to_del.tar.gz",1); find(\&archive, "$web_base/$web_to_del"); $tar->write("$defunct_dir/$web_to_del.tar.gz",1); sub archive { $tar->add_files($File::Find::name); } # line 394 ... }
I don't quite understand the warning (I am quite new to Perl). Also, the files are archived with the full path from root. Preferably, I would like the files to get stored from the relative path of the web directory. I haven't been able to get this to work properly. For example, the way the tar files get created now:Variable "$tar" will not stay shared at web_admin.pl line 394.
The way I want them:/long/full/path/to/webdir /long/full/path/to/webdir/www ...
This is just a preference, but it would be nice.webdir/ webdir/www webdir/cgi-bin ...
If anyone has any suggestions on a better way to do this I would glady appreciate them.
Thanks,
Bren
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Better way to use File::Find and Archive::Tar
by btrott (Parson) on Mar 17, 2001 at 01:03 UTC | |
|
Re: Better way to use File::Find and Archive::Tar
by merlyn (Sage) on Mar 17, 2001 at 00:25 UTC | |
by brendonc (Novice) on Mar 17, 2001 at 00:48 UTC | |
by buckaduck (Chaplain) on Mar 17, 2001 at 04:52 UTC | |
|
Re: Better way to use File::Find and Archive::Tar
by chipmunk (Parson) on Mar 17, 2001 at 00:31 UTC | |
by brendonc (Novice) on Mar 17, 2001 at 01:04 UTC |