The getservent function reads the next line from the /etc/services file.
setservent(1 );
($name, $aliases, $port, $proto) = getservent;
print "Name=$name\nAliases=$aliases\nPort=$port\nProtocol=$protocol\n";
($name, $aliases, $port, $proto) = getservent;
# Retrieves the next entry in /etc/services
print "Name=$name\nAliases=$aliases\nPort=$port\nProtocol=$protocol\n";
endservent;
Related examples in the same category