Ask a Question related to PERL Beginners, Design and Development.
-
Aman Thind #1
Archiving folder containing folders (was - RE: Using archive::tar for archiving a folder)
Thanks for the response David.
When I do 'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*.pl"))' it
tars all the .pl files in the current working directory.
However, I need to tar a folder which has many folders inside it.
I tried 'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*.*"))' and
'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*"))'
But both gave only the files in the current folder and did not recurse
inside it.
How do I archive a folder with many folders inside ? (perhaps the key lies
in glob...i searched but couldn't find a flag to make it recurse)
Thanx in advance
aman
-----Original Message-----
From: david [mailto:dzhuo@looksmart.net]
Sent: 11 February 2004 00:34
To: [email]beginners@perl.org[/email]
Subject: Re: Using archive::tar for archiving a folder
Aman Thind wrote:
Archive::Tar has a class method that does exactly like that:> Hello Friends,
>
> I wish to archive a folder into a .tar
>
> I've been searching through the documentation of archive::tar module but
> could not find a way by which I could make the .tar just by specifying the
> folder name (like on unix prompt "tar -cvf myarchive.tar myfoldername")
> and not explicitly stating the filenames.
[panda]$ perl -MArchive::Tar -e \
'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*.pl"))'
[panda]$ ls -l /tmp
-rw-r--r-- 1 x x 9216 Feb 10 10:59 test.tar
arguments to create_archive:
1. name of the archive you want to create. in your example, it would be
myarchive.tar
2. compression level from 2 to 9. any other values will use the default
level.
3. a list of files to add to the archive. in my example above, all files
ending in .pl will be archived to /tmp/test.tar
david
--
sub'_{print"@_ ";* \ = * __ ,\ & \}
sub'__{print"@_ ";* \ = * ___ ,\ & \}
sub'___{print"@_ ";* \ = * ____ ,\ & \}
sub'____{print"@_,\n"}&{_+Just}(another)->(Perl)->(Hacker)
--
To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
For additional commands, e-mail: [email]beginners-help@perl.org[/email]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
Aman Thind Guest
-
Archiving
On a new project, I'm being forced to use Contribute after years of using Movable Type for content management. My question: is there any way in... -
Help with archiving in perl.
Hi all: I'm quite new to perl and am trying to create a zip file out of chunks of binary data. here's a snippet of my code: --- use... -
Archiving in 7
I see the option to create J2EE archives, but not CAR. We are running standard. Shouldn't CAR be availble on Standard edition? -
Archiving Solutions
I'm trying to set up an archival solution. It would be for raw images, working images and final images, as well as logos. Network of 9 Macs.... -
Using archive::tar for archiving a folder
Hello Friends, I wish to archive a folder into a .tar I've been searching through the documentation of archive::tar module but could not find... -
Randy W. Sims #2
Re: Archiving folder containing folders (was - RE: Using archive::tar for archiving a folder)
On 02/11/04 06:39, Thind, Aman wrote:
something like the (untested) code below should work:> Thanks for the response David.
>
> When I do 'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*.pl"))' it
> tars all the .pl files in the current working directory.
>
> However, I need to tar a folder which has many folders inside it.
>
> I tried 'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*.*"))' and
> 'Archive::Tar->create_archive("/tmp/test.tar",0,glob("*"))'
>
> But both gave only the files in the current folder and did not recurse
> inside it.
>
> How do I archive a folder with many folders inside ? (perhaps the key lies
> in glob...i searched but couldn't find a flag to make it recurse)
>
use Archive::Tar;
use File::Find;
use strict;
use warnings;
my @files;
find sub {
return if -d;
push @files, $File::Find::name;
}, 'Module-Build'
Archive::Tar->create_archive( 'test.tar', @files );
Randy W. Sims Guest



Reply With Quote

