laziness, impatience, and hubris | |
PerlMonks |
Re: Adding scalars but with a twist..by davido (Cardinal) |
on Feb 14, 2005 at 03:15 UTC ( [id://430671]=note: print w/replies, xml ) | Need Help?? |
Remember how in your previous thread I mentioned that the global symbol table is, itself, a hash? So here's the strategy: grep the global symbol table's keys for names that match the pattern " /Sel\d+Ttl/". That's all the variables you're looking for. Next, iterate through those 'keys', dereferencing the global symbol table to get at the values held in those key names (variable names). Here's an example in action. Remember, I warned you previously this is a road to perdition. I'll see you in hell. ;) (just teasing)
Magic! Update: I realize that you could just dereference the individual keynames, as in $$_, within the foreach loop, but I left the use of the global symbol hash in the code so that future maintainers would know without a doubt that there is something going on here that needs further investigation to understand. $$_ isn't obvious enough to cry out, "I'm a symbolic ref! Beware!" Dave
In Section
Seekers of Perl Wisdom
|
|