Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hmm. Ok, well this brings up another question. I guess I kind of assumed that "our" variables were just another way of declaring variables that could be used throughout the main program. Now that I think of it, I guess that makes no sense. Which, er might mean I'm using that incorrectly.

If you declare a "local" variable with "my" in the main scope, you can still access it in all of the subroutines in the program. So, how is using "our" different than that? Is that similar to declaring something "public" in an object in java? i.e. if I were creating an object everyone could access (change?) an "our" declared variable, while a "my" declared variable ... not accessible? Or not changeable?

Update: ok, little trip to our has revealed that I appear to have been completely wrong, except for the parts I was right about. Something which I'm still not clear about though is the accessibility of "our" vs. "my" declared variables. If one can "access" them does that imply the ability to change them? I'm thinking about this as an "our" variable being able to be accessed by something outside the main scope... is it just visible, or is it mutable? (are "my" declared variables visible outside of the scope they are called in? I'm assuming definitely not mutable).

In reply to Re^2: Are global variables "bad"? by jpearl
in thread Are global variables "bad"? by jpearl

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 wandering the Monastery: (3)
As of 2024-03-29 05:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found