my @drives2check = ('S:/','T:/','X:/','D:/'); my @dis_drives = (); foreach my $drive (@drives2check) { print "Checking $drive\n"; opendir (DRIVE, $drive) or do { push @dis_drives, $drive; print "$drive : $!\n"; next; }; close DRIVE; } if (scalar @dis_drives) { # Mail the list of disconnected drives }