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 .