in reply to creating variables in a loop
Decades of advances in the science of computer programming have brought us to a point in language development where variable variable names have become both shunned, and in most languages, not even possible. This has come to be the case for very good reasons, thought up by some smart people, and punctuated by the collective experience of many many more average people as well as a few dummies along the way who got lucky.
Perl is one of those languages that has benefitted from the collective experience of the decades, along with the specific knowlege of a few really smart people. And that is how Perl came to have a pragma known as 'strict'. Strictures are Perl's way of keeping you from falling into the pit of despair that can come from venturing down the road of symbolic references without the realization that there is almost always a better approach. Now this isn't to say that some really really smart people (and a few average lucky ones) haven't come up with some darn good uses of symbolic references in Perl. And in fact Perl's designer(s) have left us with the capability to use them, unlike many other languages. But the odds are very strong that this isn't one of those times where it could be considered a good idea to use them.
Use an array of fourty members, or use a hash. You know, Perl's global variables themselves belong to a global symbol table hash. If it's good enough for Perl, it's good enough for you too... but don't muck with Perl's hash, get your own. :) Just because the neighborhood has its own gate doesn't mean that you shouldn't have a lock on your front door too...
Dave
|
|---|