#! perl -slw use strict; my( $hostname, @dnsservers, $nodetype ); my $last = ''; while () { chomp; if ( /Host Name.*?:\s*(.*)$/ ) { $hostname = $1; $last = 'host'; } elsif ( /DNS Servers.*?:\s*(.*)$/ ) { @dnsservers = $1; $last = 'dns'; } elsif ( /Node Type.*?:\s*(.*)$/ ) { $nodetype = $1; $last = 'node'; } elsif( !/:/ and $last eq 'dns' ) { print '?'; push @dnsservers, $1 if /\s+(\S+)$/; } else{ warn "Unknown linetype at $. : '$_'\n"; } } print $hostname, $/, join' | ', @dnsservers, $/, $nodetype; __DATA__ Host Name . . . . . . . . . : LAPTOP.no.cox.net DNS Servers . . . . . . . . : 205.152.132.211 181.171.2.11 10.10.10.1 Node Type . . . . . . . . . : Broadcast #### #! perl -slw use strict; my $ipConfig = do{ local $/; }; my $hostName = $1 if $ipConfig =~ m[Host Name . . . . . . . . . : (\S+)\s*\n]gc; my @dnsIPs = $ipConfig =~ m[(?:\s*([0-9.]+)\n)]gc if $ipConfig =~ m[DNS Servers . . . . . . . . :]gc; my $nodeType = $1 if $ipConfig =~ m[Node Type . . . . . . . . . : (\S+)\s*\n]; print $hostName, $/, join( ' | ', @dnsIPs), $/, $nodeType; __DATA__ Host Name . . . . . . . . . : LAPTOP.no.cox.net DNS Servers . . . . . . . . : 205.152.132.211 181.171.2.11 10.10.10.1 Node Type . . . . . . . . . : Broadcast #### #! perl -slw use strict; my $ipConfig = do{ local $/; }; my( $hostName, @dnsIPs, $nodeType ); if( $ipConfig =~ m[Host Name . . . . . . . . . : (\S+)\s*\n]gc ) { $hostName = $1; } if( $ipConfig =~ m[DNS Servers . . . . . . . . :]gc ) { @dnsIPs = $ipConfig =~ m[(?:\s*([0-9.]+)\n)]gc; } if( $ipConfig =~ m[Node Type . . . . . . . . . : (\S+)\s*\n] ) { $nodeType = $1; } print $hostName, $/, join( ' | ', @dnsIPs), $/, $nodeType; __DATA__ Host Name . . . . . . . . . : LAPTOP.no.cox.net DNS Servers . . . . . . . . : 205.152.132.211 181.171.2.11 10.10.10.1 Node Type . . . . . . . . . : Broadcast