use Archive::Tar; $tar = Archive::Tar->new(); use File::Find; $i = 0; find(\&archive, $backupdir); sub archive { if($ext) { $tar->add_files($_); $i++; } }