getpwent Function - Perl Scripting

what is getpwent function?


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;


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.


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 Protection Status

Perl Scripting Topics