{
    "mode": "perldoc",
    "parameter": "Env",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Env/json",
    "generated": "2026-06-13T21:20:48Z",
    "synopsis": "use Env;\nuse Env qw(PATH HOME TERM);\nuse Env qw($SHELL @LDLIBRARYPATH);",
    "sections": {
        "NAME": {
            "content": "Env - perl module that imports environment variables as scalars or arrays\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Env;\nuse Env qw(PATH HOME TERM);\nuse Env qw($SHELL @LDLIBRARYPATH);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Perl maintains environment variables in a special hash named %ENV. For when this access method\nis inconvenient, the Perl module \"Env\" allows environment variables to be treated as scalar or\narray variables.\n\nThe \"Env::import()\" function ties environment variables with suitable names to global Perl\nvariables with the same names. By default it ties all existing environment variables (\"keys\n%ENV\") to scalars. If the \"import\" function receives arguments, it takes them to be a list of\nvariables to tie; it's okay if they don't yet exist. The scalar type prefix '$' is inferred for\nany element of this list not prefixed by '$' or '@'. Arrays are implemented in terms of \"split\"\nand \"join\", using $Config::Config{pathsep} as the delimiter.\n\nAfter an environment variable is tied, merely use it like a normal variable. You may access its\nvalue\n\n@path = split(/:/, $PATH);\nprint join(\"\\n\", @LDLIBRARYPATH), \"\\n\";\n\nor modify it\n\n$PATH .= \":/any/path\";\npush @LDLIBRARYPATH, $dir;\n\nhowever you'd like. Bear in mind, however, that each access to a tied array variable requires\nsplitting the environment variable's string anew.\n\nThe code:\n\nuse Env qw(@PATH);\npush @PATH, '/any/path';\n\nis almost equivalent to:\n\nuse Env qw(PATH);\n$PATH .= \":/any/path\";\n\nexcept that if $ENV{PATH} started out empty, the second approach leaves it with the (odd) value\n\"\":/any/path\"\", but the first approach leaves it with \"\"/any/path\"\".\n\nTo remove a tied environment variable from the environment, assign it the undefined value\n\nundef $PATH;\nundef @LDLIBRARYPATH;\n",
            "subsections": []
        },
        "LIMITATIONS": {
            "content": "On VMS systems, arrays tied to environment variables are read-only. Attempting to change\nanything will cause a warning.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Chip Salzenberg <chip@fin.uucp> and Gregor N. Purdy <gregor@focusresearch.com>\n",
            "subsections": []
        }
    },
    "summary": "Env - perl module that imports environment variables as scalars or arrays",
    "flags": [],
    "examples": [],
    "see_also": []
}