in reply to Re: Re: reading lines
in thread reading lines
would work. Then $dnsservers is a hashref (see perldoc perlreftut if you don't know what a hashref is).my $lasttype = ''; while (<STDIN>) { s/\r|\n//gs; if ( /Host Name.*?:\s*(.*)$/ ) { $hostname = $1; print "$hostname\n"; } if ( /DNS Servers.*?:\s*(.*)$/ ) { $dnsservers = [$1]; print "$dnsservers\n"; } if ( /Node Type.*?:\s*(.*)$/ ) { $nodetype = $1; print "$nodetype\n"; } if ( /(.*):/ ) { $lasttype = $1; } elsif ( $lasttype =~ /^DNS Servers/ && /\s*(.*)$/) { push @$dnsservers, $1; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: reading lines
by spill (Novice) on Dec 07, 2003 at 04:13 UTC |