I understand. My question is that Net::Ping does not use that info at
all. If a host is alive, it will be listed in the output no matter
what port you specify. Is this a bug?

On 6/11/06, Xavier Noria <[EMAIL PROTECTED]> wrote:
On Jun 11, 2006, at 14:20, Vijay Kumar Adhikari wrote:

> This is from http://perldoc.perl.org/Net/Ping.html
>
>    # Like tcp protocol, but with many hosts
>    $p = Net::Ping->new("syn");
>    $p->{port_num} = getservbyname("http", "tcp");
>    foreach $host (@host_array) {
>      $p->ping($host);
>    }
>    while (($host,$rtt,$ip) = $p->ack) {
>      print "HOST: $host [$ip] ACKed in $rtt seconds.\n";
>    }
>
> Can some body tell me what the following line does?
>    $p->{port_num} = getservbyname("http", "tcp");

The object in $p is a blessed hashref. That's Perl object-oriented
jargon, if you are not familiar with it think $p is a regular
hashref. In any case,

   $p->{port_num} = $value;

assigns $value to the key "port_num" of the hash %$p.

That usage is a bit unusual, normally the underlying implementation
of an object is not public for clients, and access to its
"attributes" in the case of hashrefs is normally encapsulated in
method calls.

Anyway, that's what that code means.

-- fxn



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>





--
Vijay

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to