NAME
Symbol::Get - Read Perl’s symbol table programmatically
SYNOPSIS
package Foo;
our $name = 'haha';
our @list = ( 1, 2, 3 );
our %hash = ( foo => 1, bar => 2 );
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');
#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();
DESCRIPTION
Occasionally I have need to reference a variable programmatically. This module facilitates that by providing an easy, syntactic-sugar-y, read-only interface to the symbol table.
The SYNOPSIS above should pretty well cover usage.
SEE ALSO
LICENSE
This module is licensed under the same license as Perl.