I can print the 2 lines that I am looking for....
Original content restored by GrandFather below
here is what I tried-
file.txt
--------------
object-group network HOSTNAME_1ST
network-object host 10.1.1.1
object-group service WEB_TCP tcp
port-object eq 80
--------------
Trying to get the 1st 2 lines while matching an ip address.
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})$/);
}
it gives me an error - Use of uninitialized value $_ in pattern match (m//) at .......