my @temp_filelist; my $temppath = $TEMP_PATH; $temppath =~ s/\\/\\\\/g; find(\&wanted, $TEMP_PATH); # this is called for each file in $TEMP_PATH sub wanted { my $path = $File::Find::dir; $path =~ s|^$temppath||o; $path =~ s|[\\/]|$dc|g; $path =~ s|^[\\/]||; push @temp_filelist, "$path${dc}$_"; } my $tar = Archive::Tar->new(); foreach (@temp_filelist) { #print "$_\n"; $tar->add_files("$_"); } #$tar->add_files(@temp_filelist); $tar->write("$OUTPUT_FILE.gz",1); @temp_filelist = $tar->list_files();