foreach $tmp (@{$input}) { SWITCH: { if($tmp =~m/$regex1/) { last SWITCH; } if($tmp =~m/$regex2/) { last SWITCH; } if($tmp eq '..') { last SWITCH; } if($tmp eq '.') { last SWITCH; } ### DEFAULT unless(-d "$path$tmp") { push @tmparr, $tmp; } } }