if (!defined($foo) or $foo =~ m/^\??$/) { # Foo is valid }