Debian Codegraph @

upstream/opensuse-tumbleweed/man3/Env.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "Env 3pm"
61 .TH Env 3pm 2026-03-09 "perl v5.42.1" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 Env \- perl module that imports environment variables as scalars or arrays
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 3
71 \& use Env;
72 \& use Env qw(PATH HOME TERM);
73 \& use Env qw($SHELL @LD_LIBRARY_PATH);
74 .Ve
75 .SH DESCRIPTION
76 .IX Header "DESCRIPTION"
77 Perl maintains environment variables in a special hash named \f(CW%ENV\fR. For
78 when this access method is inconvenient, the Perl module \f(CW\*(C`Env\*(C'\fR allows
79 environment variables to be treated as scalar or array variables.
80 .PP
81 The \f(CWEnv::import()\fR function ties environment variables with suitable
82 names to global Perl variables with the same names. By default it
83 ties all existing environment variables (\f(CW\*(C`keys %ENV\*(C'\fR) to scalars. If
84 the \f(CW\*(C`import\*(C'\fR function receives arguments, it takes them to be a list of
85 variables to tie; it\*(Aqs okay if they don\*(Aqt yet exist. The scalar type
86 prefix \*(Aq$\*(Aq is inferred for any element of this list not prefixed by \*(Aq$\*(Aq
87 or \*(Aq@\*(Aq. Arrays are implemented in terms of \f(CW\*(C`split\*(C'\fR and \f(CW\*(C`join\*(C'\fR, using
88 \&\f(CW$Config::Config{path_sep}\fR as the delimiter.
89 .PP
90 After an environment variable is tied, merely use it like a normal variable.
91 You may access its value
92 .PP
93 .Vb 2
94 \& @path = split(/:/, $PATH);
95 \& print join("\en", @LD_LIBRARY_PATH), "\en";
96 .Ve
97 .PP
98 or modify it
99 .PP
100 .Vb 2
101 \& $PATH .= ":/any/path";
102 \& push @LD_LIBRARY_PATH, $dir;
103 .Ve
104 .PP
105 however you\*(Aqd like. Bear in mind, however, that each access to a tied array
106 variable requires splitting the environment variable\*(Aqs string anew.
107 .PP
108 The code:
109 .PP
110 .Vb 2
111 \& use Env qw(@PATH);
112 \& push @PATH, \*(Aq/any/path\*(Aq;
113 .Ve
114 .PP
115 is almost equivalent to:
116 .PP
117 .Vb 2
118 \& use Env qw(PATH);
119 \& $PATH .= ":/any/path";
120 .Ve
121 .PP
122 except that if \f(CW$ENV{PATH}\fR started out empty, the second approach leaves
123 it with the (odd) value "\f(CW\*(C`:/any/path\*(C'\fR", but the first approach leaves it with
124 "\f(CW\*(C`/any/path\*(C'\fR".
125 .PP
126 To remove a tied environment variable from
127 the environment, assign it the undefined value
128 .PP
129 .Vb 2
130 \& undef $PATH;
131 \& undef @LD_LIBRARY_PATH;
132 .Ve
133 .SH LIMITATIONS
134 .IX Header "LIMITATIONS"
135 On VMS systems, arrays tied to environment variables are read\-only. Attempting
136 to change anything will cause a warning.
137 .SH AUTHOR
138 .IX Header "AUTHOR"
139 Chip Salzenberg <\[email protected]\fR>
140 and
141 Gregor N. Purdy <\[email protected]\fR>