----- Original Message -----
From: "andrew Black" <[EMAIL PROTECTED]>
To: "perl-win32-users" <[email protected]>
Sent: Sunday, June 12, 2005 7:53 PM
Subject: Finding user home dir
> Hi
> Is there a platform independent way of getting the users home directory.
> The following work on various platforms :
> $ENV{ USERPROFILE }
> $ENV{ HOME }
> $ENV{ SYS$LOGIN}
>
I think you would need to first determine the operating system. Something
along the lines of :
use warnings;
print "Home directory is ", get_home_directory(), "\n";
sub get_home_directory {
if($^O =~ /MSwin32/i) { return $ENV{USERPROFILE}}
elsif($^O =~ /linux/i){return $ENV{HOME}}
else {# return whatever's appropriate}
}
__END__
It's easily deduced from the above that I don't know which environment
variable you need to get hold of for operating systems other than linux and
Win32 ... so I guess you would need to have that additional info as well in
order to write a fully portable function.
Cheers,
Rob
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs