#Here I am zipping all the files in a specific directory $dir = $main_path_only; # This variable will have all the path to directories that has *.log file(s). $zip = Archive::Zip->new(); $zipped; #Chopped log files and Zipped files will be created in the directories below: my $zip_file = $arch_path."/".$dir_archive."/"."$month$date-$year"."-newlog.zip"; $zipped = $zip->addDirectory( $dir); $zipped->desiredCompressionMethod( COMPRESSION_DEFLATED ); find(\&zip_file, $dir); die 'write error' unless $zip->writeToFileNamed( $zip_file ) == AZ_OK; #End archiving ######ZIP SUB################################ sub zip_file { #$zipped = $zip->addFile( $File::Find::name ); if ($File::Find::name =~ m/\.log$/i){ $zipped = $zip->addFile( $File::Find::name ); } } #####END ZIP SUB###########################