Waayyyyy offtopic. But here goes:

On Wednesday, 2002-09-11 at 04:06:20 -0500, [EMAIL PROTECTED] wrote:

> I am trying to use the following program to archive directories of large
> files but I can not get any wildcard combination to work:

Archive::Tar does not do Wildcards.

> #!/usr/bin/perl
> use Archive::Tar;

> Archive::Tar->create_archive ("test.tar", 9, "backup/*.*");

>From perldoc Archive::Tar:
           The remaining arguments list the files to be included
           in the tar file.  These files must all exist.  Any
           files which don\'t exist or can\'t be read are
           silently ignored.

I.e. You would add a file *named* "backup/*.*".

> How can I get this to tar the entire backup directory? And if I wanted to
> say pic out all file based on extensions later on like .pl *.pl how to do
> that as well with this?

Combine this with File::Find:

my $tar = Archive::Tar->new();
find({ wanted => \&wanted, no_chdir => 1}, "backup");
$tar->write("test.tar.gz", 9);

sub wanted {
  return unless /\.pl$/ and -f $_; # Only files named *.pl
  print "Adding $_\n";
  $tar->add_files($_);


You could use glob() to expand "*.*", but you still wouldn't get any
recursion into subdirecties. With File::Find you can use any test you
like. Note that $_ contains the file*path* starting at "backup" with the
no_chdir option. This differs from normal behaviour (i.e. with no_chdir
unset).

HTH,
Lupe Christoph
-- 
| [EMAIL PROTECTED]       |           http://www.lupe-christoph.de/ |
| Big Misunderstandings #6398: The Titanic was not supposed to be        |
| unsinkable. The designer had a speech impediment. He said: "I have     |
| thith great unthinkable conthept ..."                                  |

Reply via email to