You could filter directly with the grep statement something like this
#!perl
use strict;
use Date::Calc qw(Today Add_Delta_YMD);
# calc dates
my $yesterday = sprintf "%4d%02d%02d",Add_Delta_YMD(Today(),0, 0,-1);
my $lastmonth = sprintf "%4d%02d%02d",Add_Delta_YMD(Today(),0,-1,-1);
print "Yesterday : $yesterday\n";
print "Last Month : $lastmonth\n";
# path to folders
my $path = 'c:/temp';# or $DirCoolOut
opendir(D,$path) or die "Can't open the directory $path : $!\n";
my @folders = grep {/$yesterday|$lastmonth/} readdir(D);
for my $folder (@folders){
print "Zipping folder $folder\n";
# zip folders
}
poj