in reply to Re: Re: Retrieve unix group membership for a uid in a perl CGI
in thread Retrieve unix group membership for a uid in a perl CGI

Actually yours (possibly mistakenly) assumes that the user's primary group is named after their username. While this is a common default value used by some variants of adduser or the like, it's not necessarily always the case. Which is of course why you should use getpwname to retrieve their primary gid and then translate that with getgrgid.