MAN page from RedHat Other perl-5.004-0.1.i386.rpm
Symbol
Section: Perl Programmers Reference Guide (3)
Updated: perl 5.004, patch 04
Index NAME
Symbol - manipulate Perl symbols and their names
SYNOPSIS
use Symbol;
$sym = gensym; open($sym, "filename"); $_ = <$sym>; # etc.
ungensym $sym; # no effect
print qualify("x"), "\n"; # "Test::x" print qualify("x", "FOO"), "\n" # "FOO::x" print qualify("BAR::x"), "\n"; # "BAR::x" print qualify("BAR::x", "FOO"), "\n"; # "BAR::x" print qualify("STDOUT", "FOO"), "\n"; # "main::STDOUT" (global) print qualify(\*x), "\n"; # returns \*x print qualify(\*x, "FOO"), "\n"; # returns \*x use strict refs; print { qualify_to_ref $fh } "foo!\n"; $ref = qualify_to_ref $name, $pkg; DESCRIPTION
Symbol::gensym creates an anonymous glob and returns a referenceto it. Such a glob reference can be used as a file or directoryhandle.
For backward compatibility with older implementations that didn'tsupport anonymous globs, Symbol::ungensym is also provided.But it doesn't do anything.
Symbol::qualify turns unqualified symbol names into qualifiedvariable names (e.g. ``myvar'' -> ``MyPackage::myvar"). If it is given asecond parameter, qualify uses it as the default package;otherwise, it uses the package of its caller. Regardless, globalvariable names (e.g. ``STDOUT'', ``ENV'', ``SIG") are always qualfied with``main::''.
Qualification applies only to symbol names (strings). References areleft unchanged under the assumption that they are glob references,which are qualified by their nature.
Symbol::qualify_to_ref is just like Symbol::qualify except that itreturns a glob ref rather than a symbol name, so you can use the resulteven if use strict 'refs' is in effect.
Index
- NAME
- SYNOPSIS
- DESCRIPTION
This document was created byman2html,using the manual pages.