Install Perl 5.8.8
[msysgit.git] / mingw / html / lib / Symbol.html
blob87d19d3e0a93066cdad2605bb8ef902fe8fe4940
1 <?xml version="1.0" ?>
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">
4 <head>
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:" />
8 </head>
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">&nbsp;Symbol - manipulate Perl symbols and their names</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
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>
26 </ul>
27 <!-- INDEX END -->
29 <hr />
30 <p>
31 </p>
32 <h1><a name="name">NAME</a></h1>
33 <p>Symbol - manipulate Perl symbols and their names</p>
34 <p>
35 </p>
36 <hr />
37 <h1><a name="synopsis">SYNOPSIS</a></h1>
38 <pre>
39 use Symbol;</pre>
40 <pre>
41 $sym = gensym;
42 open($sym, &quot;filename&quot;);
43 $_ = &lt;$sym&gt;;
44 # etc.</pre>
45 <pre>
46 ungensym $sym; # no effect</pre>
47 <pre>
48 # replace *FOO{IO} handle but not $FOO, %FOO, etc.
49 *FOO = geniosym;</pre>
50 <pre>
51 print qualify(&quot;x&quot;), &quot;\n&quot;; # &quot;Test::x&quot;
52 print qualify(&quot;x&quot;, &quot;FOO&quot;), &quot;\n&quot; # &quot;FOO::x&quot;
53 print qualify(&quot;BAR::x&quot;), &quot;\n&quot;; # &quot;BAR::x&quot;
54 print qualify(&quot;BAR::x&quot;, &quot;FOO&quot;), &quot;\n&quot;; # &quot;BAR::x&quot;
55 print qualify(&quot;STDOUT&quot;, &quot;FOO&quot;), &quot;\n&quot;; # &quot;main::STDOUT&quot; (global)
56 print qualify(\*x), &quot;\n&quot;; # returns \*x
57 print qualify(\*x, &quot;FOO&quot;), &quot;\n&quot;; # returns \*x</pre>
58 <pre>
59 use strict refs;
60 print { qualify_to_ref $fh } &quot;foo!\n&quot;;
61 $ref = qualify_to_ref $name, $pkg;</pre>
62 <pre>
63 use Symbol qw(delete_package);
64 delete_package('Foo::Bar');
65 print &quot;deleted\n&quot; unless exists $Foo::{'Bar::'};</pre>
66 <p>
67 </p>
68 <hr />
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
72 handle.</p>
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
78 of the glob.</p>
79 <p><code>Symbol::qualify</code> turns unqualified symbol names into qualified
80 variable names (e.g. ``myvar'' -&gt; ``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
84 ``main::''.</p>
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
93 explicitly.</p>
94 <p>
95 </p>
96 <hr />
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">&nbsp;Symbol - manipulate Perl symbols and their names</span></strong></big>
107 </td></tr>
108 </table>
110 </body>
112 </html>