use strict; use Regexp::Common; while ( my $word = ) { chomp $word; if ( $word =~ /$RE{profanity}/ ) { print "Profanity detected: \"$word\"\n"; } else { print "$word\n"; } } __DATA__ aaaabbbbcccc aaaaXXXXcccc ddddeeeeffff