Perl getlogin Function



Description

This function returns the user's name, as discovered by the system function getlogin( ). Under Windows, use the Win32::LoginName( ) function instead.

Syntax

Following is the simple syntax for this function −

getlogin

Return Value

This function returns undef on failure and user's login name on success.

Example

Following is the example code showing its basic usage −

#!/usr/bin/perl

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

print "Login ID is $login\n";

When above code is executed, it produces the following result −

Login ID is apache 
perl_function_references.htm
Advertisements