I'm trying to figure out how to grab the username or login id on a unix/linux os. I figured out how to grab the username on a windows os (see the code below):
# Grab username from PC:
my $author= "$^O user";
if ($^O =~ /mswin/i)
{
$author= $ENV{USERNAME} if defined $ENV{USERNAME};
}
else
{
$author = "$first $mid $last";
}
I use the variable $author to print the username in a new file for documentation purposes. My perl script will be used on both Windows and Unix/Linux operating systems, so I'd like to include the ability to determine either. Any help is greatly appreciated.
Thanks,
Jeremy Webb