Just my $0.02... can't help offering a slight rewrite of David's great
program.
Now it's runnable on 5.010 and earlier, and should give out some warnings
if hoststatus sections are somehow corrupt:

$|++; # comment it out if you don't need to buffer the output
my $section_started;
my ($host, $state);
while(<DATA>) {
    if ($section_started) {
        $host = $1, next if /host_name=(\w+)/;
        $state = $1, next if /current_state=(\d+)/;
        if (/^\s*}\s*$/) {
            print defined $host && defined $state
                ? "$host:$state\n"
                : "Invalid section started at $section_started\n";
            $section_started = 0;
        }
    }
    else {
        $section_started = $., ($host, $state) = () if /hoststatus\s*{/;
    }
}

-- iD

2012/2/1 Brandon Phelps <bphe...@gls.com>

> Thanks a ton David,
>
> This will definitely help!  Not able to try it now but I'll give it a shot
> first thing tomorrow.
>
> -Brandon
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

Reply via email to