macx666 has asked for the wisdom of the Perl Monks concerning the following question:
When I am not using warnings or strict, line 47 does not error, and when I am using a single port (80 possibly), it does not error. Mind you, I modify it so that it does not try to do the foreach loop on the ports in the latter possibility...Starting Ping System Service at arbornet.org on port: ARRAY(0x804b424) is down Can't use an undefined value as a symbol reference at ./new_ping.pl li +ne 47.
#!/usr/local/bin/perl use IO::Socket; use strict; use warnings; # default port my $pt = "8080"; my $inactive; my $call; my $server_ip; my @remote_server; my @remote_port; $remote_server[0] = "arbornet.org"; $remote_port[0][0] = "21"; $remote_port[0][1] = "23"; $remote_port[0][2] = "80"; #$remote_server[1] = "slashdot.org"; #$remote_port[1][0] = "80"; #$remote_server[2] = "apple.com"; #$remote_port[2][0] = "80"; #$remote_server[3] = "yahoo.com"; #$remote_port[3][0] = "80"; my $i = 0; print "Starting Ping System\n"; foreach $server_ip (@remote_server){ print "\nService at $server_ip on port:\n"; foreach $pt ($remote_port[$i]){ $inactive = 0; $call = IO::Socket::INET-> new ( PeerAddr => "$server_ip", PeerPort => "$pt", Proto => 'tcp', Timeout => '5', ) or $inactive = 1; if (!($inactive)) { print " $pt is up\n"; } else { print " $pt is down\n"; } close $call; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with multidimensional arrays and IO::Socket
by Abigail-II (Bishop) on Aug 29, 2002 at 17:27 UTC | |
|
Re: Help with multidimensional arrays and IO::Socket
by fglock (Vicar) on Aug 29, 2002 at 17:29 UTC | |
|
Re: Help with multidimensional arrays and IO::Socket
by sauoq (Abbot) on Aug 29, 2002 at 20:02 UTC | |
|
Re: Help with multidimensional arrays and IO::Socket
by macx666 (Beadle) on Aug 29, 2002 at 18:17 UTC | |
by BrowserUk (Patriarch) on Aug 29, 2002 at 18:33 UTC | |
by fglock (Vicar) on Aug 29, 2002 at 18:25 UTC |