Debian Codegraph @

upstream/debian-unstable/man3/Symbol.3perl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (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 .\"
57 .IX Title "Symbol 3perl"
58 .TH Symbol 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 Symbol \- manipulate Perl symbols and their names
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 .Vb 1
68 \& use Symbol;
69 \&
70 \& $sym = gensym;
71 \& open($sym, \*(Aq<\*(Aq, "filename");
72 \& $_ = <$sym>;
73 \& # etc.
74 \&
75 \& ungensym $sym; # no effect
76 \&
77 \& # replace *FOO{IO} handle but not $FOO, %FOO, etc.
78 \& *FOO = geniosym;
79 \&
80 \& print qualify("x"), "\en"; # "main::x"
81 \& print qualify("x", "FOO"), "\en"; # "FOO::x"
82 \& print qualify("BAR::x"), "\en"; # "BAR::x"
83 \& print qualify("BAR::x", "FOO"), "\en"; # "BAR::x"
84 \& print qualify("STDOUT", "FOO"), "\en"; # "main::STDOUT" (global)
85 \& print qualify(\e*x), "\en"; # returns \e*x
86 \& print qualify(\e*x, "FOO"), "\en"; # returns \e*x
87 \&
88 \& use strict refs;
89 \& print { qualify_to_ref $fh } "foo!\en";
90 \& $ref = qualify_to_ref $name, $pkg;
91 \&
92 \& use Symbol qw(delete_package);
93 \& delete_package(\*(AqFoo::Bar\*(Aq);
94 \& print "deleted\en" unless exists $Foo::{\*(AqBar::\*(Aq};
95 .Ve
96 .SH DESCRIPTION
97 .IX Header "DESCRIPTION"
98 \&\f(CW\*(C`Symbol::gensym\*(C'\fR creates an anonymous glob and returns a reference
99 to it. Such a glob reference can be used as a file or directory
100 handle.
101 .PP
102 For backward compatibility with older implementations that didn't
103 support anonymous globs, \f(CW\*(C`Symbol::ungensym\*(C'\fR is also provided.
104 But it doesn't do anything.
105 .PP
106 \&\f(CW\*(C`Symbol::geniosym\*(C'\fR creates an anonymous IO handle. This can be
107 assigned into an existing glob without affecting the non-IO portions
108 of the glob.
109 .PP
110 \&\f(CW\*(C`Symbol::qualify\*(C'\fR turns unqualified symbol names into qualified
111 variable names (e.g. "myvar" \-> "MyPackage::myvar"). If it is given a
112 second parameter, \f(CW\*(C`qualify\*(C'\fR uses it as the default package;
113 otherwise, it uses the package of its caller. Regardless, global
114 variable names (e.g. "STDOUT", "ENV", "SIG") are always qualified with
115 "main::".
116 .PP
117 Qualification applies only to symbol names (strings). References are
118 left unchanged under the assumption that they are glob references,
119 which are qualified by their nature.
120 .PP
121 \&\f(CW\*(C`Symbol::qualify_to_ref\*(C'\fR is just like \f(CW\*(C`Symbol::qualify\*(C'\fR except that it
122 returns a glob ref rather than a symbol name, so you can use the result
123 even if \f(CW\*(C`use strict \*(Aqrefs\*(Aq\*(C'\fR is in effect.
124 .PP
125 \&\f(CW\*(C`Symbol::delete_package\*(C'\fR wipes out a whole package namespace. Note
126 this routine is not exported by default\-\-you may want to import it
127 explicitly.
128 .SH BUGS
129 .IX Header "BUGS"
130 \&\f(CW\*(C`Symbol::delete_package\*(C'\fR is a bit too powerful. It undefines every symbol that
131 lives in the specified package. Since perl, for performance reasons, does not
132 perform a symbol table lookup each time a function is called or a global
133 variable is accessed, some code that has already been loaded and that makes use
134 of symbols in package \f(CW\*(C`Foo\*(C'\fR may stop working after you delete \f(CW\*(C`Foo\*(C'\fR, even if
135 you reload the \f(CW\*(C`Foo\*(C'\fR module afterwards.