------------------------------------------------ On 04 Aug 2003 14:08:29 -0700, Bryan Irvine <[EMAIL PROTECTED]> wrote:
> I'm trying to build a script to automagically black-list spammers. How > can I extract the ip address from between [ ]? > > turn this: > > Received: from 24.60.195.149 (h00a0cce008a4.ne.client2.attbi.com > [24.60.195.149]) > Received: from 11.139.74.233 ([11.139.74.233]) by n7.groups.yahoo.com > with NNFMP; May, 17 2003 1:51:07 AM +0700 > Received: from 30.215.79.204 ([30.215.79.204]) by m10.grp.snv.yahoo.com > with SMTP; May, 17 2003 12:44:43 AM -0800 > > into this: > > 24.60.195.149 > 11.139.74.233 > 30.215.79.204 > Assuming there is only one set of brackets on a line, and you only want the IP address between them, and READLOG is an open handle to your log: - Not Tested - my @ips; while (my $line = <READLOG>) { if ($line =~ /\[(.*)\]/) { push @ips, $1; } else { print STDERR "no ip in line\n"; } } print "@ips\n"; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]