#!/usr/bin/perl -w use strict; use IO::Socket::PortState qw(check_ports); my $proto = 'tcp'; #my $port = '8307'; my $address = '127.0.0.1'; my %hash = (); open( OUT, "" ) || die "Problems during the writing $!"; while () { %hash = (); my ( $key, $port ) = split( '=', $_ ); $hash{$key} = $port; my ( $section, $ping_timeout, %porthash ); $porthash{$proto}{$port}{'name'} = $section; check_ports( $address, $ping_timeout, \%porthash ); my $open = $porthash{$proto}{$port}{'open'}; if ($open) { print "port : $port alive\n"; } else { print "port : $port dead\n"; } }