( categories: system | special variables )
Use the following predefined variables to get the user and group information belonging to the current process:
- $< - real user id (uid); unique value
- $> - effective user id (euid); unique value
- $( - real group id (gid); list (separated by spaces) of groups
- $) - effective group id (egid); list (separated by spaces) of groups
NOTES:
- This information applies only to Unix systems
- The values that theses variables hold are integers.
To get the user and group names, use '(getpwuid($<))[0]' (for user information) and 'getgrgid($()' (for groups).
Examples:
#-- check if running as root
print "Running as root!!\n" if ( $< == 0 );
#-- print username
print "Your username is " . (getpwuid($<))[0] . "\n";
#-- print groups information
@groups = split '\s', $(;
print "You belong to these groups: ";
print getgrgid($_) . " " foreach(@groups);
print "\n";





