in reply to reading lines
I don't know about the rest of your output, but if it's mostly like the lines you've shown us, then why not do something like this? (Caveat scriptor, this code is untested)
my ($name,$val,%hostinof); while (<>) { if ($name && /^\s+(.*)/) { push @{$hostinfo{$name}}, $1); next } if (($name,$val) = /^(\w[\s\w]+) [ .]+:\s*(.*)/) { $name = lc $name; $hostinfo{$name} = [ $val ]; } else { $name = '' ] }
Then your %hostinfo hash contains keys for "host name", "dns servers", and "node type" that are all references to anonymous arrays which contain the values you want.
|
|---|