perl_dedicted has asked for the wisdom of the Perl Monks concerning the following question:
output is :#!/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 = (); #########This works ######################################## my($section, $ping_timeout, %porthash); $porthash{$proto}{$port}{'name'} = $section; print "here is the $port"; check_ports($address, $ping_timeout, \%porthash); my $open = $porthash{$proto}{$port}{'open'}; if ($open) { print "alive\n"; } else { print "dead\n"; } #################################################################
output is :#!/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, "<location of the file>" ) || die "Problems during the writing $!"; while (<OUT>) { %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"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Usage of IO::Socket::PortState
by Anonymous Monk on Sep 04, 2015 at 04:36 UTC |