2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml">
5 <title>Symbol - manipulate Perl symbols and their names
</title>
6 <meta http-equiv=
"content-type" content=
"text/html; charset=utf-8" />
7 <link rev=
"made" href=
"mailto:" />
10 <body style=
"background-color: white">
11 <table border=
"0" width=
"100%" cellspacing=
"0" cellpadding=
"3">
12 <tr><td class=
"block" style=
"background-color: #cccccc" valign=
"middle">
13 <big><strong><span class=
"block"> Symbol - manipulate Perl symbols and their names
</span></strong></big>
17 <p><a name=
"__index__"></a></p>
22 <li><a href=
"#name">NAME
</a></li>
23 <li><a href=
"#synopsis">SYNOPSIS
</a></li>
24 <li><a href=
"#description">DESCRIPTION
</a></li>
25 <li><a href=
"#bugs">BUGS
</a></li>
32 <h1><a name=
"name">NAME
</a></h1>
33 <p>Symbol - manipulate Perl symbols and their names
</p>
37 <h1><a name=
"synopsis">SYNOPSIS
</a></h1>
42 open($sym,
"filename
");
46 ungensym $sym; # no effect
</pre>
48 # replace *FOO{IO} handle but not $FOO, %FOO, etc.
49 *FOO = geniosym;
</pre>
51 print qualify(
"x
"),
"\n
"; #
"Test::x
"
52 print qualify(
"x
",
"FOO
"),
"\n
" #
"FOO::x
"
53 print qualify(
"BAR::x
"),
"\n
"; #
"BAR::x
"
54 print qualify(
"BAR::x
",
"FOO
"),
"\n
"; #
"BAR::x
"
55 print qualify(
"STDOUT
",
"FOO
"),
"\n
"; #
"main::STDOUT
" (global)
56 print qualify(\*x),
"\n
"; # returns \*x
57 print qualify(\*x,
"FOO
"),
"\n
"; # returns \*x
</pre>
60 print { qualify_to_ref $fh }
"foo!\n
";
61 $ref = qualify_to_ref $name, $pkg;
</pre>
63 use Symbol qw(delete_package);
64 delete_package('Foo::Bar');
65 print
"deleted\n
" unless exists $Foo::{'Bar::'};
</pre>
69 <h1><a name=
"description">DESCRIPTION
</a></h1>
70 <p><code>Symbol::gensym
</code> creates an anonymous glob and returns a reference
71 to it. Such a glob reference can be used as a file or directory
73 <p>For backward compatibility with older implementations that didn't
74 support anonymous globs,
<code>Symbol::ungensym
</code> is also provided.
75 But it doesn't do anything.
</p>
76 <p><code>Symbol::geniosym
</code> creates an anonymous IO handle. This can be
77 assigned into an existing glob without affecting the non-IO portions
79 <p><code>Symbol::qualify
</code> turns unqualified symbol names into qualified
80 variable names (e.g. ``myvar'' -
> ``MyPackage::myvar''). If it is given a
81 second parameter,
<code>qualify
</code> uses it as the default package;
82 otherwise, it uses the package of its caller. Regardless, global
83 variable names (e.g. ``STDOUT'', ``ENV'', ``SIG'') are always qualified with
85 <p>Qualification applies only to symbol names (strings). References are
86 left unchanged under the assumption that they are glob references,
87 which are qualified by their nature.
</p>
88 <p><code>Symbol::qualify_to_ref
</code> is just like
<code>Symbol::qualify
</code> except that it
89 returns a glob ref rather than a symbol name, so you can use the result
90 even if
<code>use strict 'refs'
</code> is in effect.
</p>
91 <p><code>Symbol::delete_package
</code> wipes out a whole package namespace. Note
92 this routine is not exported by default--you may want to import it
97 <h1><a name=
"bugs">BUGS
</a></h1>
98 <p><code>Symbol::delete_package
</code> is a bit too powerful. It undefines every symbol that
99 lives in the specified package. Since perl, for performance reasons, does not
100 perform a symbol table lookup each time a function is called or a global
101 variable is accessed, some code that has already been loaded and that makes use
102 of symbols in package
<code>Foo
</code> may stop working after you delete
<code>Foo
</code>, even if
103 you reload the
<code>Foo
</code> module afterwards.
</p>
104 <table border=
"0" width=
"100%" cellspacing=
"0" cellpadding=
"3">
105 <tr><td class=
"block" style=
"background-color: #cccccc" valign=
"middle">
106 <big><strong><span class=
"block"> Symbol - manipulate Perl symbols and their names
</span></strong></big>