in reply to Re: Parsing multiple lines based on a given String
in thread Parsing multiple lines based on a given String
Original content restored by GrandFather below
here is what I tried-Trying to get the 1st 2 lines while matching an ip address.file.txt -------------- object-group network HOSTNAME_1ST network-object host 10.1.1.1 object-group service WEB_TCP tcp port-object eq 80 --------------
it gives me an error - Use of uninitialized value $_ in pattern match (m//) at .......use strict; use warnings; my $iphostname; my $filename = 'file.txt'; open(my $fh, '<:encoding(UTF-8)', $filename) or die "Could not open file '$filename' $!"; for $iphostname ($fh) { print $iphostname if (/^object-group/ ... /(\d{1,3})\.(\d{1,3})\.(\d +{1,3})\.(\d{1,3})$/); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Parsing multiple lines based on a given String
by choroba (Cardinal) on Jun 22, 2016 at 16:21 UTC | |
by ArifS (Beadle) on Jun 22, 2016 at 16:43 UTC | |
|
Re^3: Parsing multiple lines based on a given String
by Marshall (Canon) on Jun 22, 2016 at 17:20 UTC | |
by choroba (Cardinal) on Jun 22, 2016 at 20:35 UTC | |
by Marshall (Canon) on Jun 22, 2016 at 21:03 UTC | |
|
Re^3: Parsing multiple lines based on a given String
by Marshall (Canon) on Jun 22, 2016 at 22:07 UTC | |
by ArifS (Beadle) on Jun 27, 2016 at 15:23 UTC |