Jas wrote:
> Not sure if this is the way it is supposed to work, but I am not sure
> how I can get a directory, like a web directory backed up in one step
> using Archive::Tar.
>
> Code...
>
> #!/usr/bin/perl
>
> use strict;
> use Archive::Tar;
>
> my $bu = Archive::Tar->create_archive("www.tar",0,glob("/path/to/www/*"));
>
> This only grabs files under www/, it doesn't touch the directories. I
> am still new to perl and have been looking at the Archive::Tar
> documentation on Cpan but it doesn't give an example of how this can be
> accomplished. Any help is appreciated.
if you haven't been looking at the Archive::Tar documentation, how do you
know it doesn't give you an example of how this can be done?
assume you have the following directory structure:
/path/to/www/readme.txt
/path/to/www/htdocs/index.html
/path/to/www/htdocs/home.html
/path/to/www/htdocs/login.html
/path/to/www/cgi-bin/login.pl
/path/to/www/cgi-bin/process.cgi
/path/to/www/cgi-bin/secure/password.pl
and you want to tar everything under /path/to/www as www.tar, you can do
something similiar like:
#!/usr/bin/perl -w
use strict;
use File::Find;
use Archive::Tar;
my @files;
find(sub {push @files,$File::Find::name},'/path/to/www');
Archive::Tar->create_archive("www.tar",0,@files);
__END__
if you haven't, you *really* should:
perldoc File::Find
perldoc Archive::Tar
david
--
s$s*$+/<tgmecJ"ntgR"tgjvqpC"vuwL$;$;=qq$
\x24\x5f\x3d\x72\x65\x76\x65\x72\x73\x65
\x24\x5f\x3b\x73\x2f\x2e\x2f\x63\x68\x72
\x28\x6f\x72\x64\x28\x24\x26\x29\x2d\x32
\x29\x2f\x67\x65\x3b\x70\x72\x69\x6e\x74
\x22\x24\x5f\x5c\x6e\x22\x3b\x3b$;eval$;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>