Symbol...::Name(3pm)
π NAME π
okay so bestie, <rainbow>Symbol::Global::Name</rainbow> β it finds the name and type of a global variable. that's it, that's the whole job, and it does it flawlessly π
this one lives in the manual as Symbol...::Name(3pm) iykyk (the name got squished, it happens, she's still iconic) π
β¨ SYNOPSIS β¨
like, look how easy this is:
package My;
our $VERSION = '0.1';
use Symbol::Global::Name;
print Symbol::Global::Name->find( \$VERSION );
# prints '$My::VERSION'
literally three lines of setup and then boom, you got the name π¦
πΈ DESCRIPTION πΈ
so what's the vibe? it goes and lookups symbol table to find an element by reference. that's the whole thing. you hand it a reference, it hands you back the name. no cap. π
π METHODS π
π₯ find π₯
Symbol::Global::Name->find( \$VERSION );
Symbol::Global::Name->find( \$VERSION, package => 'My::Package' );
Symbol::Global::Name->find( reference => \$VERSION );
Symbol::Global::Name->find( reference => \$VERSION, package => 'My::Package' );
okay so here's the tea β β find takes a reference and an optional package name.
what it gives you back is the name of the referenced variable, as long as it's in the package or sub-package and it's a global variable. two conditions, bestie, both gotta pass π«Ά
and the returned name comes prefixed with the type sigil, eg. '$', '@', '%', '&' or '*'. so it's not just the name, it's the whole glow-up with the sigil attached β¨
note that both call styles work β positional\$VERSIONor the namedreference => \$VERSIONβ andpackage => 'My::Package'is optional in both. you pick your fighter π
π AUTHOR π
Ruslan Zakirov <ruz@bestpractical.com> β thank you for your service, king π
π LICENSE π
Under the same terms as perl itself. iconic behavior, honestly π
okay that's the whole page bestie!! this was documented in perl v5.36.0, dated 2022-11-19, and the manual name is Symbol...::Name(3pm). go forth and find your globals πβ¨π¦
π¦ where this page comes from
- debian bookworm: libsymbol-global-name-perl 0.05-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libsymbol-global-name-perl 0.05-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libsymbol-global-name-perl 0.05-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsymbol-global-name-perl 0.05-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsymbol-global-name-perl 0.05-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms