Perl functions references-getnetent Function - Perl Scripting

what is getnetent function in Perl? what is its syntax?


This function gets the next entry from the /etc/networks file, returning − ($name, $aliases, $addrtype, $net)
If /etc/networks file signifies empty, then it would not return anything and call will fail..


Following is the simple syntax for this function −

Return Value

This function returns undef on error otherwise Network address in scalar context and empty list on error otherwise Network record (name, aliases, address type, network address) in list context.


Following is the example code showing its basic usage −
When above code is executed, it produces the following result −

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

Perl Scripting Topics