# exceptions dictionary our @Exceptions = ( 'game cocks', 'gamecocks', #etc ); # censor dictionary our @Vulgarities = ( 'cocks', 'cock', #etc ); $censored = censor($post); sub censor{ # get a copy of the post my $copy = shift; # remove all exceptions for $except (@exceptions){ $copy =~ s/$except//gi; } # now check for banned words or phrases for $vulgar (@vulgarities){ if ($copy =~ /$vulgar/i){ return 1; } } return; }