in reply to Re: Using 'and'
in thread Array Woes
TMTOWTDI, of course, but I'd prefer to say:
#!/usr/bin/perl use strict; use warnings; use IO::Socket::INET; my @host = qw[ 192.168.1.3 192.168.46.2 ]; my $port = 22; foreach (@host) { check($_, $port); } sub check { my ($ip, $port) = @_; print ( my $sock = IO::Socket::INET->new( PeerAddr => $ip, PeerPort => $port, Proto => 'tcp', timeout => 10, ) ? "$ip is listening on port $port\n" : "$ip is NOT listening on port $port.\n" ) }
But then again, I'm a sucker for the ternary operator.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Using 'and'
by tadman (Prior) on Dec 12, 2002 at 22:20 UTC | |
by agentv (Friar) on Dec 12, 2002 at 23:50 UTC | |
by LAI (Hermit) on Dec 13, 2002 at 14:50 UTC | |
by tadman (Prior) on Dec 13, 2002 at 18:00 UTC | |
|
Re: Re: Re: Using 'and'
by agentv (Friar) on Dec 12, 2002 at 23:48 UTC |