User Control Panel
|
|
|
 |
Advertisements
|
 |
|
|
|
HELP US, HELP YOU!
|
| Author |
Message |
MxT Young One

Joined: 26 Nov 2005 Posts: 65
      
|
Posted: Fri Jan 20, 2006 12:54 am Post subject: Insult |
|
|
Hi, i want to make a insult detector for my chat. but i dont know how to do something like if the message is equal to example any word in a array like
| Code: |
@insult = ("asshole", "stupid", "fool");
if($message =~ /@insulte/si)
{
$self->sendMessage("Dont swear please !");
}
|
Plz it will improve it. |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Fri Jan 20, 2006 1:06 am Post subject: |
|
|
You could join the array into something regexp-friendly.
| Code: | my $regexp = join ('|', @insult);
if ($message =~ /$regexp/si) {
$self->sendMessage ("Dont swear please !");
} |
_________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
MxT Young One

Joined: 26 Nov 2005 Posts: 65
      
|
Posted: Fri Jan 20, 2006 2:33 am Post subject: Thank cer |
|
|
Thank cer, its work  |
|
| Back to top |
|
 |
|
|