in reply to How can I grep these IP-addresses from these logfiles?

#! /usr/bin/perl use strict; #BUILD IP LIST open(IPS, 'ip.txt') || die "Can't open IP.txt: $!\n"; my $iplist = join('|', map {chomp;quotemeta} <IPS>); close(IPS); my $re = qr/$iplist/; #READ IN LOG FILE my @log = map {chomp;$_} <DATA>; #Check for matches my @matches = grep /$re/, @log; print "$_\n" foreach(@matches); __DATA__ 1.1.2.1 1.3.4.5 192.168.0.1 1.2.3.4 4.5.6.7 10.0.0.1
ip.txt
192.168.0.1 1.1.1.1 10.0.0.1
Output:
192.168.0.1
10.0.0.1

Update: Add contents of ip.txt, which made the output make more sense.
Combined 2 map statements into 1 when reading in ip.txt.

- Tom