On Wed, Jun 27, 2001 at 02:37:55AM -0400, Adam Theo wrote:
> i am looking for a way my perl program can automatically get the home
> directory of the user.
There is, of course, the HOME environmental variable. There is also
(getpwuid $>)[7], which gets the home directory from the password database,
using the current UID. There are variations, such as
(getpwnam $ENV{LOGNAME})[7] and (getpwnam $ENV{USER})[7].
> i have come accross the ENV module, and think it will work, but wish to
> know if it is a standard module with all perl distributions?
It is. Env.pm is just a way for turning environmental variables into global
variables. You can get to the values through the %ENV hash.
> linux, windows, mac, etc? also, what does ENV do for windows and mac
> users, since those are not typically milti-user OSes? and finally, while
> i have found the ENV, does anyone know of a better way to do this? thank
> you for your time.
I know Windows has environmental variables, and Perl can get to them. I'm
not sure if $ENV{HOME} will have a sane value, or any value at all. There
is no real concept of a home directory anyways, unless you count the primary
hard drive, aka C. You could probably get away with checking $^O for some
variation on "Win32" and hard-coding your home directory based on that.
I can't help you with Mac, though Mac also doesn't have a concept of home
directory (AFAIK), so doing the bit with $^O would probably work there as
well.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--