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; } }
In reply to Re: Re: Re: reading lines
by ysth
in thread reading lines
by spill
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |