in reply to using m// while iterating through an array
However, I'd use a hash:#!/usr/bin/perl -w use strict; chomp(my @banned_channels = <DATA>); my $channels = "#gross_people #skriptk1dd13\$ #trolls"; sub IRC::print { print "@_\n"; } foreach (@banned_channels) { if ($channels =~ /$_/i) { IRC::print "match: $_"; } } __END__ #trolls #flamers #lusers #litterbugs
my $channels = "#gross_people #skriptk1dd13\$ #trolls"; my %banned; @banned{split " ", $channels} = (1); foreach (@banned_channels) { if (exists($banned{$_})) { IRC::print "match: $_"; } }
|
|---|