{
    "mode": "perldoc",
    "parameter": "Symbol",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Symbol/json",
    "generated": "2026-06-16T22:28:44Z",
    "synopsis": "use Symbol;\n$sym = gensym;\nopen($sym, '<', \"filename\");\n$ = <$sym>;\n# etc.\nungensym $sym;      # no effect\n# replace *FOO{IO} handle but not $FOO, %FOO, etc.\n*FOO = geniosym;\nprint qualify(\"x\"), \"\\n\";              # \"main::x\"\nprint qualify(\"x\", \"FOO\"), \"\\n\";       # \"FOO::x\"\nprint qualify(\"BAR::x\"), \"\\n\";         # \"BAR::x\"\nprint qualify(\"BAR::x\", \"FOO\"), \"\\n\";  # \"BAR::x\"\nprint qualify(\"STDOUT\", \"FOO\"), \"\\n\";  # \"main::STDOUT\" (global)\nprint qualify(\\*x), \"\\n\";              # returns \\*x\nprint qualify(\\*x, \"FOO\"), \"\\n\";       # returns \\*x\nuse strict refs;\nprint { qualifytoref $fh } \"foo!\\n\";\n$ref = qualifytoref $name, $pkg;\nuse Symbol qw(deletepackage);\ndeletepackage('Foo::Bar');\nprint \"deleted\\n\" unless exists $Foo::{'Bar::'};",
    "sections": {
        "NAME": {
            "content": "Symbol - manipulate Perl symbols and their names\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Symbol;\n\n$sym = gensym;\nopen($sym, '<', \"filename\");\n$ = <$sym>;\n# etc.\n\nungensym $sym;      # no effect\n\n# replace *FOO{IO} handle but not $FOO, %FOO, etc.\n*FOO = geniosym;\n\nprint qualify(\"x\"), \"\\n\";              # \"main::x\"\nprint qualify(\"x\", \"FOO\"), \"\\n\";       # \"FOO::x\"\nprint qualify(\"BAR::x\"), \"\\n\";         # \"BAR::x\"\nprint qualify(\"BAR::x\", \"FOO\"), \"\\n\";  # \"BAR::x\"\nprint qualify(\"STDOUT\", \"FOO\"), \"\\n\";  # \"main::STDOUT\" (global)\nprint qualify(\\*x), \"\\n\";              # returns \\*x\nprint qualify(\\*x, \"FOO\"), \"\\n\";       # returns \\*x\n\nuse strict refs;\nprint { qualifytoref $fh } \"foo!\\n\";\n$ref = qualifytoref $name, $pkg;\n\nuse Symbol qw(deletepackage);\ndeletepackage('Foo::Bar');\nprint \"deleted\\n\" unless exists $Foo::{'Bar::'};\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "\"Symbol::gensym\" creates an anonymous glob and returns a reference to it. Such a glob reference\ncan be used as a file or directory handle.\n\nFor backward compatibility with older implementations that didn't support anonymous globs,\n\"Symbol::ungensym\" is also provided. But it doesn't do anything.\n\n\"Symbol::geniosym\" creates an anonymous IO handle. This can be assigned into an existing glob\nwithout affecting the non-IO portions of the glob.\n\n\"Symbol::qualify\" turns unqualified symbol names into qualified variable names (e.g. \"myvar\" ->\n\"MyPackage::myvar\"). If it is given a second parameter, \"qualify\" uses it as the default\npackage; otherwise, it uses the package of its caller. Regardless, global variable names (e.g.\n\"STDOUT\", \"ENV\", \"SIG\") are always qualified with \"main::\".\n\nQualification applies only to symbol names (strings). References are left unchanged under the\nassumption that they are glob references, which are qualified by their nature.\n\n\"Symbol::qualifytoref\" is just like \"Symbol::qualify\" except that it returns a glob ref rather\nthan a symbol name, so you can use the result even if \"use strict 'refs'\" is in effect.\n\n\"Symbol::deletepackage\" wipes out a whole package namespace. Note this routine is not exported\nby default--you may want to import it explicitly.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "\"Symbol::deletepackage\" is a bit too powerful. It undefines every symbol that lives in the\nspecified package. Since perl, for performance reasons, does not perform a symbol table lookup\neach time a function is called or a global variable is accessed, some code that has already been\nloaded and that makes use of symbols in package \"Foo\" may stop working after you delete \"Foo\",\neven if you reload the \"Foo\" module afterwards.\n",
            "subsections": []
        }
    },
    "summary": "Symbol - manipulate Perl symbols and their names",
    "flags": [],
    "examples": [],
    "see_also": []
}