foreach my $char (a..d) { print "bbb matches $char\n" if "bbb" =~ /[$char]/; } #### bbb matches b