Perl Programming/Keywords/getlogin

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Previous: gethostent Keywords Next: getnetbyaddr

The getlogin keyword[edit | edit source]

The getlogin function implements the same C library function. On most UNIX-like systems, this function returns the current login from /etc/utmp, if any. On an empty string, the function getpwuid should be used.

As getlogin is not as safe as getpwuid, the latter should be used for authentication.

Syntax[edit | edit source]

 getlogin

Examples[edit | edit source]

 $login = getlogin || getpwuid($<) || "Kilroy";

See also[edit | edit source]

Previous: gethostent Keywords Next: getnetbyaddr