in reply to System Variables

If you're after system environment variables, have a look at the ENV hash.

For example, to get the current user's home directory on a UNIX host ($HOME in shell) try :

#!/usr/bin/perl use strict; use warnings; print $ENV{'HOME'}, "\n";

Cheers.

BazB

Replies are listed 'Best First'.
Re: Re: System Variables
by archen (Pilgrim) on Oct 09, 2002 at 23:33 UTC
    might be a little more informative if you do something such as:
    foreach( keys %ENV ) { print "$_ = $ENV{$_} \n"; }
    Since what varables are available may vary from system to system. Of course just wanting to know "system variables" is sort of a vague question...
      Or perhaps more economically,
      while(my ($key, $val) = each %ENV) { print "$key = $val\n"; }
      since you're not sorting the keys anyway.

      Makeshifts last the longest.

        I'm just feeling a bit silly...
        perl -e'print$_,$|--?$/:qq?$"=$"?for%ENV'

        -Blake