Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Filtering one array using another array

by Kimi_1973 (Initiate)
on Sep 04, 2003 at 13:40 UTC ( [id://288866]=note: print w/replies, xml ) Need Help??


in reply to Filtering one array using another array

Try the following:
#!/usr/bin/perl # example blacklisting @sites = ( "http://www.rtfm.com", "http://www.alottatax.com", "http://www.kingdom.com/cgi-bin/script.pl" ); @blacklist = ( "cgi", "blabla", "testme" ); foreach $site (@sites) { &blacklist(); } sub blacklist { foreach $blacklist (@blacklist) { if ( $site =~ m/$blacklist/gi ) { print "$site blacklisted - $blacklist\n"; return; #Change1 } else { print "$site ok\n"; return; #Change2 } } }

Replies are listed 'Best First'.
Re: Re: Filtering one array using another array
by teabag (Pilgrim) on Sep 04, 2003 at 13:53 UTC
    Yup, that works in this example. But it seems to be working only for the first word in @blacklist?


    Teabag
    Sure there's more than one way, but one just needs one anyway - Teabag

Re: Re: Filtering one array using another array
by Kimi_1973 (Initiate) on Sep 04, 2003 at 13:50 UTC
    Plese Ingore the Changes1,2 .

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://288866]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-24 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found