use Regex::PreSuf; my @ignore = qw( 192.168.188.3 192.168.11.141 192.168.140.110 192.168.186.192 192.168.186.166 192.168.139.50 192.168.139.198 192.168.132.101 ); my $ignorex = presuf( map { s|\.|\\.|g } @ignore );