Re: $ENV HOME on windows
- From: "Dr.Ruud" <rvtol+news@xxxxxxxxxxxx>
- Date: Sun, 22 Apr 2007 18:53:47 +0200
Bob schreef:
I apologise for the basic question, but I am using perl on windows for
the first time (after about 20 years using it on unix...) and the
problem does not make sense to me. Perl (active state) complaints that
the value is not initialized. Why in heaven?
#!/usr/bin/perl -w
use strict;
use diagnostics;
print $ENV{HOME};
Do a `set` in a CMD shell console window, or use perl:
perl -wle "print qq{$_=$ENV{$_}} for sort keys %ENV"
(which will show the keys in allcaps)
and you'll see something like
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\Username
The concatenation can be used as HOME:
BEGIN {
if ( substr ( $^O, 0, 5 ) eq q{MSWin} ) {
if ( $ENV{HOME} ) {
# leave as is
}
elsif ( $ENV{USERPROFILE} ) {
$ENV{HOME} = $ENV{USERPROFILE};
}
elsif ( $ENV{HOMEDRIVE} and $ENV{HOMEPATH} ) {
$ENV{HOME} = $ENV{HOMEDRIVE} . $SENV{HOMEPATH};
}
else {
$ENV{HOME} = '.';
} } }
There are also modules on the cpan that do something alike.
--
Affijn, Ruud
"Gewoon is een tijger."
.
- Follow-Ups:
- Re: $ENV HOME on windows
- From: Ilya Zakharevich
- Re: $ENV HOME on windows
- From: Matthew X. Economou
- Re: $ENV HOME on windows
- References:
- $ENV HOME on windows
- From: Bob
- $ENV HOME on windows
- Prev by Date: $ENV HOME on windows
- Next by Date: FAQ 4.10 Why aren't my random numbers random?
- Previous by thread: $ENV HOME on windows
- Next by thread: Re: $ENV HOME on windows
- Index(es):
Relevant Pages
|