I’m looking for a way of mapping a uid (unique number representing a system user) to a user name using Perl.
Please don’t suggest greping /etc/passwd 🙂
Edit
As a clarification, I wasn’t looking for a solution that involved reading /etc/passwd explicitly. I realize that under the hood any solution would end up doing this, but I was searching for a library function to do it for me.
The standard function
getpwuid, just like the same C function, gets user information based on its ID. Nouses needed:Although it eventually reads
/etc/passwdfile, using standard interfaces is much more clear for other users to see, let alone it saves you some keystrokes.