use strict; use warnings; my $my_name="Acidovorax JS42"; my $db_name="Acidovorax sp. JS42"; my @names = split " ", $my_name; my $numel = @names; #number of words to match my $count; foreach (@names) { if ($db_name=~/^|\s\Q$_\E$|\s/) { $count++; #count matches } } print "MATCH" if $count==$numel; #report match if all words match