in reply to && comparison not working
OUTPUT:#!/usr/bin/perl use strict; use warnings; local $/="}"; # So we can slurp an entire service in one read my $host_txt= "host_name"; my $check = "check_nrpe"; my $con = "contact_groups"; while (my $list = <DATA>){ next if $list=~/PING/; # UPDATE: O.P. Added this sample after I po +sted next unless $list=~ m/$host_txt\s+(\w+).+$check.+$con\s+(\w+)/so; print "GROUP NAME: $2; for host $1\n"; } __DATA__ define service { host_name KT service_description Check SSH check_command check_ssh max_check_attempts 1 check_interval 1 retry_interval 2 check_period 24x7 check_freshness 1 contact_groups admins notification_interval 60 notification_period 24x7 notifications_enabled 1 register 1 } define service { host_name KT service_description Controller Load check_command check_nrpe!check_load max_check_attempts 1 check_interval 1 retry_interval 2 check_period 24x7 check_freshness 1 contact_groups admins notification_interval 60 notification_period 24x7 notifications_enabled 1 register 1 }
GROUP NAME: admins; for host KT
As a computer, I find your faith in technology amusing.
|
|---|