Symbol::Get(3pm)
π Symbol::Get β the manual page, but make it cute π
okay so this is Symbol::Get(3pm), part of the User Contributed Perl Documentation bestie collection, and it's literally about reading Perl's symbol table programmatically. no cap. let's get into it π
β¨ NAME β¨
Symbol::Get β read Perl's symbol table programmatically π¦
β¨ SYNOPSIS β¨
okay so picture this, you got a package and you want to poke at its guts:
package Foo;
our $name = 'haha';
our @list = ( 1, 2, 3 );
our %hash = ( foo => 1, bar => 2 );
use constant my_const => 'haha';
use constant my_const_list => qw( a b c );
sub doit { ... }
my $name_sr = Symbol::Get::get('$Foo::name'); # \$name
my $list_ar = Symbol::Get::get('@Foo::list'); # \@list
my $hash_hr = Symbol::Get::get('%Foo::hash'); $ \%hash
#Defaults to __PACKAGE__ if none is given:
my $doit_cr = Symbol::Get::get('&doit');
#Constants:
my $const_val = Symbol::Get::copy_constant('Foo::my_const');
my @const_list = Symbol::Get::copy_constant('Foo::my_const_list');
#The below return the same results since get_names() defaults
#to the current package if none is given.
my @names = Symbol::Get::get_names('Foo'); # keys %Foo::
my @names = Symbol::Get::get_names();
and yeah, that's honestly the whole vibe. slay.
β¨ DESCRIPTION β¨
so like, occasionally I (the author, not me, I'm just the messenger π) need to reference a variable programmatically. and this module is literally the answer to that. it gives you an easy, syntactic-sugar-y, read-only interface to the symbol table. read-only!! it's giving librarian energy, not gremlin energy π
and honestly? the SYNOPSIS above covers usage pretty well. it's right there. it ate. π
πΈ ABOUT PERL CONSTANTS πΈ
okay so this is the important part, bestie, listen up π«Ά
previous versions of this module were out here endorsing constructions like:
my $const_sr = Symbol::Get::get('Foo::my_const');
my $const_ar = Symbol::Get::get('Foo::my_const_list');
β¦to read constants from the symbol table. and the way that this isn't reliable across Perl versions?? π so don't do it. periodt. instead, use copy_constant(). that's the move. no cap. β¨
π¨ bestie warning: the oldget()-on-a-constant thing is not reliable across Perl versions. this is not a drill. usecopy_constant()and be free. π
β¨ SEE ALSO β¨
Symbol::Valuesβ go look at this one too, iykyk π
β¨ LICENSE β¨
this module is licensed under the MIT License. iconic, honestly. π
and that's the whole page!! perl v5.38.2, dated 2024-04-27 β so like, this manual page is a lil vintage but she's still serving π thanks for reading bestie, go reference some variables, you got this π¦πβ¨
π¦ where this page comes from
- debian trixie: libsymbol-get-perl 0.12-1 Β· MIT
- ubuntu resolute: libsymbol-get-perl 0.12-1 Β· MIT
- ubuntu stonking: libsymbol-get-perl 0.12-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms