Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks!
I want to know if you could give me a list of known system variables!

Replies are listed 'Best First'.
Re: System Variables
by husoft (Monk) on Oct 08, 2002 at 23:08 UTC
    you mean the perl built-in system variables that can be
    referenced from every Perl program. These system variables
    are divided into five groups:

    - Global scalar variables
    - Pattern system variables
    - File system variables
    - Array system variables
    - Built-in file variables

    Get more info by clicking here!
Re: System Variables
by BazB (Priest) on Oct 09, 2002 at 11:22 UTC

    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

      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.

Re: System Variables
by Steve_p (Priest) on Oct 09, 2002 at 11:18 UTC

    No! :)

    Seriously, can you explain a little bit what you mean by system variables? Then maybe we can help.