Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Comment on




I see that even under use strict, I don't have to declare/define global variables in Perl: I just need to fully qualify them and they're already there. Is this correct? If it is, then is there any kind of "super" use strict, which helps me catch typos that my programs may have?

Also, is there any way of defining a variable like C's static (i.e., a global variable with local scope). I see that Perl's our is almost what I want, but the variable declared with our in a function is still accessible outside the function if I use the variable's fully qualified name. I fear that I don't completely understand our.

In fact, I have trouble understanding the difference between our ($i); and use vars qw($i); Can anybody help with the difference? They don't seem different to the eyes of this poor Perl newbie.

Thanks in advance for any comments.

In reply to Help needed understanding global variables in Perl by Anonymous Monk

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (8)
    As of 2014-12-25 19:39 GMT
    Find Nodes?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?

      Results (162 votes), past polls