in reply to Re^2: Extract IP from email dataset?
in thread Extract IP from email dataset?

use strict; use Regexp::Common qw /net/; my $email = q|Received: (qmail 23153 invoked from network); 14 Apr 200 +4 21:19:04 -0000 Received: from dev213.omgkitty.com (HELO omgkitty.co +m) (@192.168.2.118) by dev50.omgkitty.com with SMTP; 11 Jan 2003 22:4 +5:04 -0000 Received: (qmail 11105 invoked by uid 99); 14 Apr 2004 22: +19:04 -0000 Received: (qmail 14227 invoked from network); 14 Apr 2004 + 22:19:04 -0000 Received: from unknown (HELO ns.eisnoc1.net) (66.54.2 +18.128) by www.omgkitty.com with SMTP; 14 Apr 2004 22:45:04 -0000 Rec +eived: from listmail (216.157.143.2) by ns.eisnoc1.net (8.11.1/8.11.1 +) with ESMTP id h0BMg4000951 for <nospam@omgkitty.com>; Sat, 11 Jan 2 +003 17:42:04 -0500 Message-Id: <200301112242.h0BMg4000951@ns.eisnoc1. +net> Date: Sat, 11 Jan 2003 15:40:09 -0500 From: "Ronald George" <ron +@247customer.com> To: "Omgkitty User" <nospam@omgkitty.com> Subject: +Whats up? MIME-Version: 1.0 Content-Type: text/plain; charset="iso-88 +59-1" Content-Transfer-Encoding: 7bit X-Mailer: ListMail v1.65 X-LM-F +lags: 1.45.82 What’s up? |; while ($email =~ m/$RE{net}{IPv4}{dec}{-keep}/g) { print "$1\n"; }
Output:
192.168.2.118 66.54.218.128 216.157.143.2

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James