Copyright © tutorialspoint.com

PERL getservent Function


Syntax

getservent


Definition and Usage

Gets the next entry from the list of service entries, returning:

($name, $aliases, $port_number, $protocol_name)

This call itrate through /etc/services file.

Return Value

  • In scalar context undef on error otherwise service name

  • In list context empty list on error otherwise Service record (name, aliases, port number, protocol name).

Example

Try out following example:

#!/usr/bin/perl

while(($name, $aliases, $port_number, 
     $protocol_name) = getservent()){

   print "Name = $name\n";
   print "Aliases = $aliases\n";
   print "Port Number = $port_number\n";
   print "Protocol Name = $protocol_name\n";

}


Copyright © tutorialspoint.com