Be aware that Perl has a number of built-in functions
relating to users and groups, for
example: getlogin, getpwnam, getgrent.
See Perl functions for fetching user and group info.
The simple code below, while perhaps not meeting your
specific requirements, lists all users on a Linux box (including their home directories and other properties)
by using the Perl builtin getpwent function:
use strict;
use warnings;
while ( my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos,
$home, $shell) = getpwent ) {
print <<"ALL_USER_ATTRS";
name = $name
passwd = $passwd
uid = $uid
gid = $gid
quota = $quota
comment = $comment
gcos = $gcos
home = $home
shell = $shell
ALL_USER_ATTRS
}
See also Re: adding a group to the Unix System for example code that calls
getpwnam.