|more useful options|
Re: Multiple CGI Objects w/ Same Nameby sierrathedog04 (Hermit)
|on Jul 11, 2001 at 05:27 UTC||Need Help??|
The following code runs without error in ActiveState 5.6/WinMe when warnings is turned off:
On the other hand, it produces a "masks earlier declaration in same scope" warning when run with -w turned on.
In the code you describe your second declaration of a reference named $q masks your first declaration. The answer is, yes, you are allowed to do it.
However, the prophet Dylan said "to live outside the Law you must be honest." It says in the Talmud that "he who will not take upon himself the yoke of the Law must take upon himself the yoke of the world."
Well, it's like that in Perl also. You can live outside the Law and intentionally write programs that do not run with strict and warnings turned on. But in that case you lose the protection of the Perl gods. Then you must be honest as Dylan said, meaning that the dubious practices that -w guards against must not confuse you and induce coding errors. And you take upon yourself the yoke of the real world as the Talmudic fathers said, which means that in the real world the Perl Porters may have forgotten to test what happens to those programmers who live outside the Law, and the perl interpreter itself might have an undiscovered bug that kills your program.
It is a big world out there. There are endless opportunities to get into trouble. Why ask for trouble by living outside the Law and writing code that fails when run under the -w flag?
Consider what would have happened if Moses's mother had decided to name her son "Abraham" instead of "Moses." Then there would have been two Abrahams in the Bible, just as you have two CGI objects named 'q'. People might have become confused. "Follow Abraham out of Egypt? Abraham's dead!" The Jews might never have entered the Promised Land.
Please stop. Ask not whether thou shalt declare two references with the same variable name, for such a question is not conducive to Perl enlightenment.