Friday, April 25, 2008

Profanity filter

This will catch most of the usual ways people swear.. ie: sh!t, f*ck, etc etc.

#!/usr/bin/perl

opendir(DIR, ".") || die "$!";
@files = readdir(DIR);
close(DIR);

foreach $line (@files) {
open(F, $line) || die "$!";
while() {
if(/\b(s[h\!\|\@\-\*][i\!\|\@\-\*][t\!\|\@\-\*]){1,3}(\s+|$)/i ||
/\b(f[u\!\|\@\-\*][c\!\|\@\-\*][k\!\|\@\-\*]){1,3}(\s+|$)/i ||
/\b(a[s\!\|\@\-\*\$][s\!\|\@\-\*\$]){1,2}(\s+|$)/i ||
/\b(w[h\!\|\@\-\*][o\!\|\@\-\*0][r\!\|\@\-\*][e\!\|\@\-\*]){1,4}(\s+|$)/i ||
/\b(b[i\!\|\@\-\*][t\!\|\@\-\*07][c\!\|\@\-\*][h\!\|\@\-\*]){1,4}(\s+|$)/i ||
/\b(s[l\!\|\@\-\*\$][u\!\|\@\-\*\$][t\!\|\@\-\*7]){1,3}(\s+|$)/i ||
/\b(c[u\!\|\@\-\*\$][n\!\|\@\-\*\$][t\!\|\@\-\*7]){1,3}(\s+|$)/i) {

print ">> $1 found in $line - $_\n";

}

}

}

No comments: