mattwortho has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I was wondering if anyone could help me parsing an Azureus log file to obtain only the received IP addresses. I am working researching how efficient the locality aware part of the client is. I would be most grateful for help. Many thanks, Matt. PS log looks like:
07:35:09.930 0 net Sent [BT_REQUEST piece #77:507904->524287] mess +age . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +. . . . . . . .TorrentDLM: 'Ubuntu-ISO'; Peer: R: 70.248.116.237: 548 +32 [µTorrent 1.7.2] 07:35:09.954 0 net Received [BT_PIECE data for piece #77:622592->6 +38975] message . . . . . . . . . . . . . . . . . . . . . . . . . . . +. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + . . . . . . . TorrentDLM: 'Ubuntu-ISO'; Peer: L: 70.50.142.197: 6298 +8 [µTorrent 1.7.2]
etc And I would like to get from these lines just the received information in the form of TIME <space> IP address

Replies are listed 'Best First'.
Re: Parse Azureus Log File
by bart (Canon) on Jul 31, 2007 at 11:46 UTC
    It looks to me like the key phrase are in the word "Peer" followed by, what, an "L" or an "R"? (sounds like "left" or "right" to me, judging by this short sample), the IP address, and the port number. Good, let's try to match that.
    local $\ = "\n"; # line feed at end of print while(<>) { if(/\bPeer: (\w):\s+(\d+\.\d+\.\d+\.\d+):\s*(\d+)/) { print $2; } }
    Does that help?

    n.b. I've foreseen some requirement changes so I'm capturing the letter ("L", "R") and the port number too.

    Update: it looks to me like you edited your question to include the time too. Fixing:

    local($\, $,) = ("\n", " "); while(<>) { if(/([\d:.]+).*?\bPeer: (\w):\s+(\d+\.\d+\.\d+\.\d+):\s*(\d+)/) { print $1, $3; } }