Hi,
I have a text file with information containing computer ip addresses, mac addresses, os details etc that looks like this for each node:
Nmap scan report for somenode.somedomain.com (192.x.x.x)
Host is up (0.032s latency).
Not shown: 974 closed ports
PORT STATE SERVICE
53/tcp open domain
...
49160/tcp open unknown
MAC Address: 24:34:E4:57:aB:BC (some company)
Device type: general purpose
Running: Microsoft Windows 7|2008
OS CPE: cpe:/o:microsoft:windows_7::-
cpe:/o:microsoft:windows_7::sp1
cpe:/o:microsoft:windows_server_2008::sp1
cpe:/o:microsoft:windows_8
OS details: Microsoft Windows 7 SP0 - SP1, Windows Server 2008 SP1, or Windows 8
Network Distance: 1 hop
I want to get the information reorganised so it looks like this:
$IPADDRESS, $MACADDRESS, $OSCPE, $OSDETAILS
$IPADDRESS, $MACADDRESS, $OSCPE, $OSDETAILS
etc
I slurped a file and tried to get this done various ways - one of which is
<code>($IPADDR,$MACADDR,$OS,$OSDETL) = $TEXT =~ /(192\.168\.1\.\d+).*?(\d2:\d2:\d2:\d2:\d2:\d2)/g;<code>
but it doesn't work. It will work if I only use
<code>
@matches = ( $TEXT =~ /(192\.168\.1\.\d+)/g);
foreach my $val (@matches) {
print "$val\n";
<code>
But if I try to match another string in the same regular expression it fails. For example, this doesn't work:
<code>
@matches = ( $TEXT =~ /(192\.168\.1\.\d+).*?(\d2:\d2:\d2:\d2:\d2:\d2)/g);
<code>
Thanks
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |