while my $foo (@bars) { if ($foo =~ /baz/i) { goto DONE unless $foo eq uc $foo; } else { goto DONE unless $foo ne uc $foo; } DONE: do_more_stuff($foo); }