in reply to Re: Re: reading lines
in thread reading lines

It looks like you aren't slurping the file, but I'm not entirely certain. If you aren't, something like:
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; } }
would work. Then $dnsservers is a hashref (see perldoc perlreftut if you don't know what a hashref is).

Replies are listed 'Best First'.
Re: Re: Re: Re: reading lines
by spill (Novice) on Dec 07, 2003 at 04:13 UTC
    I am not slurping, is there a benefit to doing that? My data is pretty static, so i figured i could go line by line and know what to expect.