+ }
+ push @out, create_regex();
+ return @out;
+}
+
+sub create_regex
+{
+ my @out;
+ my $fh = new IO::File $regex;
+
+ if ($fh) {
+ my $s = "sub { my \$str = shift; my \@out; \n";
+ while (<$fh>) {
+ chomp;
+ next if /^\s*\#/;
+ my @list = split " ";
+ for (@list) {
+ # create a closure for each word so that it matches stuff with spaces/punctuation
+ # and repeated characters in it
+ my $w = uc $_;
+ my @l = split //, $w;
+ my $e = join '+[\s\W]*', @l;
+ $s .= "push \@out, \$1 if \$str =~ /($e)/;\n";
+ }
+ }
+ $s .= "return \@out;\n}";
+ $regexcode = eval $s;
+ dbg($s) if isdbg('badword');
+ if ($@) {
+ @out = ($@);
+ dbg($@);
+ return @out;
+ }
+ $fh->close;