getpwent Function - Perl Scripting

what is getpwent function?

Description

This function returns the next password entry from the /etc/passwd file. This is used in combination with two functions that is the setpwent and endpwent function to iterate over the password file. In a list context, returns
($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwent;

Syntax

Following is the simple syntax for this function −

Return Value

This function returns username in scalar context and user record (name, password, user ID, group ID, quote, comment, real name, home directory, shell) in list context.

Example

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

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Perl Scripting Topics