in reply to Re: Dynamic Symbol Table access
in thread Dynamic Symbol Table access
To get that hash from the string you have, you must again indulge in symrefs
You can do it with real hash keys, if you know the secret:
package Foo::Bar::Baz; use vars '$quux'; print "What should \$quux hold?\n: "; chomp( $quux = <STDIN> ); package main; use strict; my $hash = \%main::; for my $key (qw( Foo Bar Baz )) { $hash = $hash->{ $key . '::' }; } print "Quux is: ${ $hash->{quux} }\n";
|
|---|