Thank you for your replies. Sorry about the munging of the previous post. I'm trying to populate the two arrays @IPADR and @MACADR using a binding to a slurped file using captures from regular expressions shown below. In between the two captures I put "..." since I wasn't sure what to put there. I had "*." on the assumption that the second capture would limit the dot's greediness. If I remove one of the captures and just use a single related array, I can print the values. As soon as I try to put the second capture into the regular expression, I get no output and no error message (running perl -w script.pl). I thought two captures could be used to populate separate arrays but there is something I am unaware of. I'm hoping it's not something you told me previously.
the eginv.txt file that the regular expression is bound to has around 100 nodes in it, each with their own rows for mac addresses and ip addresses etc. I'd like to get the values into their respective arrays so I could print them so that each node is described on one line like this "NODENAME, IPADDRESS, MACADDRESS, SOMETHINGELSE...." Can I get that with some modifcations to what I have so far?
Thanks
This is the source of the information the script is running against sh
+owing one node of about 100.
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
my $file = 'eginv.txt';
{
local( $/ ) ;
open( my $fh, $file ) or die "Oops file dead\n";
my $TEXT = <$fh>;
my $IPADDR=();
my $MACADDR=();
my $RUN=();
my $OSDETL=();
my $HOP=();
my @MACADR=();
my @IPADR=();
(@IPADR,@MACADR) = $TEXT =~ /(192\.168\.1\.[\d]+)...([A-Fa-f0-9]{2}:[A
+-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]
+{2})/gs;
foreach my $ial (@IPADR) {
print "$ial\n";
}
# foreach my $mal (@MACADR) {
# print "$mal\n";
# }
}
|