in reply to Accessing constants via symbol table possible?
Just call the function by name. Constants are functions so... it just works. No eval necessary.
sub dump_consts { print "SINS list: @{[SINS]}\n\n"; no strict 'refs'; local $, = ' '; for my $const (keys %constant::declared) { print $const, $const -> (), "\n"; } } __DATA__ SINS list: pride envy gluttony lust anger greed sloth main::CLOUD 9 main::SINS pride envy gluttony lust anger greed sloth main::HELL system admin
Seeking Green geeks in Minnesota
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Accessing constants via symbol table possible?
by SIGSEGV (Sexton) on Feb 20, 2003 at 15:33 UTC |