in reply to reading lines
And the output -use strict; use Data::Dumper; my $config = do { local $/; <DATA> }; my @dns = map { /(\S+)/g } # grab IP numbers between DNS .. Node $config =~ m/DNS[^:]*:\s+([^N]*)\nNode/gs; print Dumper(\@dns); __DATA__ Host Name . . . . . . . . . : LAPTOP.no.cox.net DNS Servers . . . . . . . . : 205.152.132.211 181.171.2.11 10.10.10.1 Node Type . . . . . . . . . : Broadcast Point to Point Host Name . . . . . . . . . : DESKTOP.no.cox.net DNS Servers . . . . . . . . : 123.123.123.123 192.168.0.112 10.10.10.3 Node Type . . . . . . . . . : Broadcast Point to Point
$VAR1 = [ '205.152.132.211', '181.171.2.11', '10.10.10.1', '123.123.123.123', '192.168.0.112', '10.10.10.3' ];
|
|---|