Perl Home
PERL Functions
© 2011 TutorialsPoint.COM
|
PERL sethostent Function
Syntax
Definition and Usage
As gethostent() retriews the information for the next line in the host database, then sethostent sets (or resets) the enumeration to the beginning of the set of host entries. This function should be called before the first call to gethostent. The STAYOPEN argument is optional and unused on most systems.
Return Value
Example
Try out following example:
#!/usr/bin/perl
while( ($name, $aliases, $addrtype, $length, @addrs) = gethostent() ){
print "Name = $name\n";
print "Aliases = $aliases\n";
print "Addr Type = $addrtype\n";
print "Length = $length\n";
print "Addrs = @addrs\n";
}
sethostent(1);
while( ($name, $aliases, $addrtype, $length, @addrs) = gethostent() ){
print "Name = $name\n";
print "Aliases = $aliases\n";
print "Addr Type = $addrtype\n";
print "Length = $length\n";
print "Addrs = @addrs\n";
}
endhostent(); # Closes the database;
|
|

|
|
|