my @choices = qq(one two three four five); my %choices; $choices{$_}++ for @choices; while ($sth->fetch) { if (exists $choices{$var}) { # } }