use strict; use Archive::Zip qw(:ERROR_CODES); opendir(DIR, "C:\\Users\\vinayas1\\Desktop\\Automation") || die "Can't open local directory : $!"; my @zips = grep { -f "./$_" } readdir (DIR); close(DIR); foreach my $zipfiles (grep( /\.zip$/,@zips)) { print "$zipfiles\n"; if ($zipfiles =~ /\w+\.zip$/) { my $zip = Archive::Zip->new(); my $zipName = "$zipfiles"; my $status = $zip->read( $zipName); die "Read of $zipName failed\n" if $status != AZ_OK; print "$zipfiles\n"; $zip->extractTree(); #unlink($zipfiles); } }