in reply to Filtering one array using another array
See. perlre and quotemeta for more info. Also a module that might be of interest - Regex::Presuf.use strict; my @sites = ( "http://www.rtfm.com", "http://www.alottatax.com", "http://www.kingdom.com/cgi-bin/script.pl" ); my $blacklist = join '|', map quotemeta, qw/ cgi blabla testme /; for(@sites) { printf "%s %s\n", $_, $_ =~ /($blacklist)/ ? "blacklisted - $1" : 'ok'; } __output__ http://www.rtfm.com ok http://www.alottatax.com ok http://www.kingdom.com/cgi-bin/script.pl blacklisted - cgi
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Filtering one array using another array
by teabag (Pilgrim) on Sep 04, 2003 at 13:40 UTC |