Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.


In reply to Re: Multiple CGI Objects w/ Same Name by sierrathedog04
in thread Multiple CGI Objects w/ Same Name by LadyD

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found