Problems? Is your data what you think it is? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Greetings Monks! This question is probably more trouble than it's worth, but it's been bugging me, so here goes: I can create constants like so: but if I want a way to convert the number back into a string, I need to do something that defines the same relationships again, like which allows me to do things like:
My problem is, I hate that I have to maintain my constant declarations and my @num_to_name list separately. If I was doing this with a large number of constants, I'd screw it up for sure. I actually made a thing that sort of does what I want, though It's cludge-tastic and probably all wrong and unnecessarily stupid:
With that monster, $num_to_name[FOO] eq 'FOO' no matter what. It loses the inlining of use constant, which is part of what's lame about it. Is there a way to do this that sucks less? Thank you for your indulgence --Pileofrogs In reply to Crazy constant question... by pileofrogs
|
|