in reply to Array Trouble!
= isn't the right operator for substitution.$comment =~ s/$l/****/g;
Here is some working code that you should be able to modify.
which outputsmy $foo = "man, that's some badass motherfucking shit!"; my @badwords = qw/ass fuck shit/; foreach my $word (@badwords) { my $bleep = "*" x length($word); $foo =~ s/$word/$bleep/g; } print $foo, "\n";
man, that's some bad*** mother****ing ****!
Updated Formatting
Update 2 In your database, the words are one per line it seems. Therefore, the words all have a \n on the end of them, so unless the "bad" word in the comment has a newline after it, it won't match. Make the syntax correction I noted above, and add chomp($l); as the first statement in your loop, and it should work. The chomp removes the last character of a string if it is a newline.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Array Trouble!
by ACJavascript (Acolyte) on Apr 10, 2003 at 01:28 UTC |