Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Multiple CGI Objects w/ Same Name

by sierrathedog04 (Hermit)
on Jul 11, 2001 at 05:27 UTC ( #95566=note: print w/replies, xml ) Need Help??

in reply to Multiple CGI Objects w/ Same Name

The following code runs without error in ActiveState 5.6/WinMe when warnings is turned off:
use strict; my $test = 123; my $test = 456; print $test;
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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://95566]
[ambrus]: hallo, cbstream still working?
[ambrus]: nice, it rarely runs for so long without having to restart it

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2018-05-24 22:21 GMT
Find Nodes?
    Voting Booth?