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


In reply to Re^3: Extract IP from email dataset? by CountZero
in thread Extract IP from email dataset? by bharadwajh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.