- Perl Basics
- Perl - Home
- Perl - Introduction
- Perl - Environment
- Perl - Syntax Overview
- Perl - Data Types
- Perl - Variables
- Perl - Scalars
- Perl - Arrays
- Perl - Hashes
- Perl - IF...ELSE
- Perl - Loops
- Perl - Operators
- Perl - Date & Time
- Perl - Subroutines
- Perl - References
- Perl - Formats
- Perl - File I/O
- Perl - Directories
- Perl - Error Handling
- Perl - Special Variables
- Perl - Coding Standard
- Perl - Regular Expressions
- Perl - Sending Email
- Perl Advanced
- Perl - Socket Programming
- Perl - Object Oriented
- Perl - Database Access
- Perl - CGI Programming
- Perl - Packages & Modules
- Perl - Process Management
- Perl - Embedded Documentation
- Perl - Functions References
- Perl Useful Resources
- Perl - Questions and Answers
- Perl - Quick Guide
- Perl - Useful Resources
- Perl - Discussion
Perl setprotoent Function
Description
This function should be called before the first call to getprotoent. The STAYOPEN argument is optional and unused on most systems. As getprotoent() retriews the information for the next line in the protocol database, then setprotoent sets (or resets) the enumeration to the beginning of the set of host entries.
Syntax
Following is the simple syntax for this function −
setprotoent STAYOPEN
Return Value
This function does not return any value.
Example
Following is the example code showing its basic usage −
#!/usr/bin/perl while(($name, $aliases, $protocol_number) = getprotoent()) { print "Name = $name\n"; print "Aliases = $aliases\n"; print "Protocol Number = $protocol_number\n"; } setprotoent(1); # Rewind the database. while(($name, $aliases, $protocol_number) = getprotoent()) { print "Name = $name\n"; print "Aliases = $aliases\n"; print "Protocol Number = $protocol_number\n"; } endprotoent(); # Closes the database
When above code is executed, it produces the following result −
Name = ip Aliases = IP Protocol Number = 0 Name = hopopt Aliases = HOPOPT Protocol Number = 0 Name = icmp Aliases = ICMP Protocol Number = 1 Name = igmp Aliases = IGMP Protocol Number = 2 Name = ggp Aliases = GGP Protocol Number = 3 Name = ipencap Aliases = IP-ENCAP Protocol Number = 4 Name = st Aliases = ST Protocol Number = 5 . . . Name = rsvp-e2e-ignore Aliases = RSVP-E2E-IGNORE Protocol Number = 134 Name = udplite Aliases = UDPLite Protocol Number = 136 Name = mpls-in-ip Aliases = MPLS-in-IP Protocol Number = 137 Name = manet Aliases = manet Protocol Number = 138 Name = hip Aliases = HIP Protocol Number = 139 Name = shim6 Aliases = Shim6 Protocol Number = 140
perl_function_references.htm
Advertisements