Re: Help understand documentation
- From: fxn@xxxxxxxxxxx (Xavier Noria)
- Date: Sun, 11 Jun 2006 15:41:48 +0200
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
.
- Follow-Ups:
- Re: Help understand documentation
- From: Vijay Kumar Adhikari
- Re: Help understand documentation
- References:
- Help understand documentation
- From: Vijay Kumar Adhikari
- Help understand documentation
- Prev by Date: Help understand documentation
- Next by Date: Re: plugins
- Previous by thread: Help understand documentation
- Next by thread: Re: Help understand documentation
- Index(es):
Relevant Pages
- [TOOL] SSH Brute Forcer
... set dictionary [lindex $argv 0] ... set hosts ... foreach passwd
$passwords ... (Securiteam) - Re: Conflict with Net::SSH::Perl and Tk?
... >Maybe I should phrase the question better. ... sub do_ssh{ ...
my @hosts = qw; ... foreach my $host { ... (comp.lang.perl.tk) - Re: PHP Multi-threading
... action on lets say 100 different hosts in the same time. ... multi-threading
ar a way to emulate it. ... foreach ... I agree with Erwin - if you need
to use threads, PHP isn't a good way to ... (comp.lang.php)