use strict; my @restricted_words = qw (funk shucks crud); my $word = 'crudshorts'; if (grep $word =~ /$_/, @restricted_words){ print "wash your mouth out!\n"; }else{ print "Such a nice boy\n"; }