http://www.perlmonks.org?node_id=11113455

flieckster has asked for the wisdom of the Perl Monks concerning the following question:

I have a script that goes into a folder on our server, glob's all the files in it, and sends an email to me with exactly what clients files might be in that folder. the files in that folder all have elements in the filenames that i can match to an expression to identify each clients files. i would like to glob the files, then look at the files in the array and match to a list of possible matches and report back to me which client files its found. as you can see with my code below i can match with individual if statements, then list them all out in my email, but that seems wrong, plus i'd rather not have any of the "0" counts show up.
1 TUMI files 0 BW files 0 maurices files
ideally i'd list the files in one email like such. any help in modifying my code to be more scaliabe would be helpful.
1 TUMI file TUMI-1354839054_alt1 1.psd 2 maurices files maur-1111.psd maur-1110.psd
code below::
#!/usr/bin/perl -w use Net::FTP; use File::Copy; use File::Basename; use Email::Send::SMTP::Gmail; use POSIX qw(strftime); my $date = strftime("%m-%d-%y",localtime); my $time = strftime("%I:%M:%S",localtime); my $photo_error_folder = "/Volumes/photorepos/Partners/WorkHorse/ERROR +/PhotographyDrop_ERROR"; my $post_error_folder = "/Volumes/photorepos/Partners/WorkHorse/ERROR/ +PostDrop_ERROR"; my $subject = "ICS -- Files in the Error Folder "; my $dllist ='bflieck@xxx.com'; chdir( $photo_error_folder ) or print "Cant chdir to $photo_error_fold +er $!"; my $count = (@photo_err_list) = glob '"*{jpg,tif,tiff,psd}"'; if ($count > 0) { my ($mail,$error)=Email::Send::SMTP::Gmail->new( -smtp=>'smtp.gmail.co +m', -login=>'kopautomatio +n1@xxx.com', -pass=>'xxx', -layer=> 'ssl', -port=> '465', -debug=> 1, -timeout=> 1000); $tumi_count = grep { /TUMI/ } @photo_err_list; if ($tumi_count > 0) { print "$tumi_count TUMI files\n"; } else { print "$tumi_count TUMI files\n"; } $bw_count = grep { /BW/ } @photo_err_list; if ($bw_count > 0) { print "$bw_count BW files\n"; } else { print "$bw_count BW files\n"; } $maurices_count = grep { /Maur/ } @photo_err_list; if ($maurices_count > 0) { print "$maurices_count Maurices files\n"; } else { print "$maurices_count maurices files\n"; } my $body="please fix and redrop or delete the<br> file://$photo_error_folder/<br><br> "; my $spacer ="<br>"; my $body1= join "<br>\n", @photo_err_list; $mail->send(-to=>"$dllist", -from=>"$dllist", -subject=>"$subject", -b +ody=>"$body $spacer $body1", -contenttype=>"text/html"); $mail->bye; }