
Kenosis
User
Mar 8, 2013, 9:52 AM
Post #2 of 5
(124 views)
|
|
Re: [yanivr78] matching 2 regex IP
[In reply to]
|
Can't Post
|
|
Consider using Regexp::Common to capture the IPs:
use strict; use warnings; use Regexp::Common qw /net/; while (<DATA>) { if ( my ( $source, $destination ) = (/($RE{net}{IPv4})/g)[ 1, 2 ] ) { print "$source -> $destination\n"; } } __DATA__ Dec 4 20:25:21 10.85.254.10 %ASA-6-106100: access-list inside permitted tcp inside/10.80.20.25(42940) -> pscdmz/155.16.61.33(3181) hit-cnt 1 first hit [0xffe8f8cb, 0x75d65ece] Dec 4 20:25:22 10.85.254.10 %ASA-6-106100: access-list inside permitted tcp inside/155.16.61.33(42940) -> pscdmz/10.80.20.25(3181) hit-cnt 1 first hit [0xffe8f8cb, 0x75d65ece] Output:
10.80.20.25 -> 155.16.61.33 155.16.61.33 -> 10.80.20.25 Hope this helps! Edit: Have placed the regex in a conditional, just in case a line exists w/o the IPs.
(This post was edited by Kenosis on Mar 8, 2013, 4:54 PM)
|