foreach my $folder (@logfolders, '') { # Do rest of stuff here }