Re: Help understand documentation
- From: vijay@xxxxxxxxxx (Vijay Kumar Adhikari)
- Date: Tue, 13 Jun 2006 09:59:30 +0545
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 <fxn@xxxxxxxxxxx> 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: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
<http://learn.perl.org/> <http://learn.perl.org/first-response>
--
Vijay
.
- Follow-Ups:
- Re: Help understand documentation
- From: Xavier Noria
- Re: Help understand documentation
- References:
- Help understand documentation
- From: Vijay Kumar Adhikari
- Re: Help understand documentation
- From: Xavier Noria
- Help understand documentation
- Prev by Date: Re: How easily I can solve this
- Next by Date: Problem reading HTTP POST request using STDIN
- Previous by thread: Re: Help understand documentation
- Next by thread: Re: Help understand documentation
- Index(es):