
japhy
Enthusiast
May 29, 2000, 1:03 PM
Post #2 of 7
(539 views)
|
|
Re: Delete Certain Elements From Array
[In reply to]
|
Can't Post
|
|
Here's a pretty complete solution. <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> # an array of our bad words @badwords = ( "BAD", "NAUGHTY", "NASTY", "TABOO", "UNGOOD", "EVIL", "ICKY", ); # can also do: @badwords = qw( BAD NAUGHTY NASTY TABOO UNGOOD EVIL ICKY ); # construct the bad-word regex $bad_REx = join "|", map quotemeta, @badwords; # filter out the bad stuff @safe_data = grep !/$bad_REx/io, @data; # the /i is for case-insensitive matching # the /o is "compile this regex once" </pre><HR></BLOCKQUOTE>
|