Re: $ENV HOME on windows



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."

.



Relevant Pages

  • Re: $ENV HOME on windows
    ... the first time and the ... Perl (active state) complaints that ...
    (comp.lang.perl.misc)
  • Re: Executing commands through Perl
    ... Its my first time using Perl and I would like some help in performing some relatively simple operations. ... You have to munge it before output. ... I want to know how to call a command line utility through Perl. ...
    (perl.beginners)
  • Re: Executing commands through Perl
    ... Its my first time using Perl and I would like some ... actually program names) to yum, to be installed into a Unix machine. ... I'm extracting the names using "split" command and pushing ...
    (perl.beginners)
  • Re: [OT] Re: Placement of {
    ... > Today, for the first time in my life, I'm half my father's age. ... > My STLFilt tool's main component is written in Perl. ... indexes into hashes of hashes of hashes of hashes of hashes...., ... Before you start the next Perl program, ...
    (comp.lang.cpp)
  • Re: sed/awk, instead of Perl
    ... Perl for sed-ly stuff. ... wump$ ls -l Desktop/klog ... sys 0m0.250s ... The very first time I ran this, ...
    (freebsd-questions)