that @constants will contain numbers and that you'll be checking whether or not a constant by that name exists...which it won't.Hmm, well maybe my function doesn't do what the OP requested (quite possible since it was written pre-1pm ;) but it will do what I intended - given a list of strings return if they exist in a given package e.g
And if you want to go from constant values to constant names then check out chromatic's Devel::Constants module.sub UNIVERSAL::which_constants { my($class, @constants) = @_; return grep exists $constant::declared{"$class\::$_"}, @constants; } use constant FOO => "a string"; use constant BAR => [ qw/ an array / ]; use constant BAZ => { qw/ a hash / }; print "constant exists - $_\n" for main->which_constants( qw/ ichi FOO bar BAZ one DEUX / ); __output__ constant exists - FOO constant exists - BAZ
_________
broquaint
In reply to Re: Re: Re: managing constants created with constant.pm
by broquaint
in thread managing constants created with constant.pm
by bakunin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |