my @list = split /,/, $thestring; if(grep { $_ == $thecheck } @list) { print "Found it!\n"; } # Or, if you need this a lot: # preparation: my %set; $set{$_} = 1 foreach split /,/, $thestring; # actual test: if($set{$thecheck}) { print "Found it!\n"; }