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
    Hi dio,

    I have to apologize for this long delay until giving feedback, but I only come round here so seldomly.

    Your hint was absolutely right. I should have had a look at the source of constant.pm (by invoking perldoc with the -m switch) to realize that the constants are only inlined subs.

    Regards