in reply to Accessing constants via symbol table possible?

Learn to love the Devel:: namespace, I do ;)
use Devel::Symdump; use strict; use warnings; use constant SINS => qw(pride envy gluttony lust anger greed sloth) +; my $dS = Devel::Symdump->new(__PACKAGE__); local $\="\n"; print " here are some constants (prototype '')"; for my $f( $dS->functions ) { my $p = prototype $f; print $f if defined $p and $p eq ''; } __END__ here are some constants (prototype '') main::SINS


MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
** The Third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: Accessing constants via symbol table possible?
by ihb (Deacon) on Feb 07, 2003 at 16:46 UTC
    Unfortunately your snippet will report subroutines that aren't constants as constants. Try adding
    my $foo = 1; sub foo () { $foo++ }
    ihb
      I know (that can only be determined through constant.pm like you know). You should've mentioned the fact that I completely missed the question.

      update: you see me saying you in italycs like that, imagine i'm nodding at you as I say it, mmkay.

      Also, chromatic also likes the Devel:: namespace ;)


      MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
      ** The Third rule of perl club is a statement of fact: pod is sexy.