Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I assume what raybies was referring to was that unless $a is within a scope that encloses the subroutine (which it is in your case but may not necessarily be in the OP's case) then it *can* be modified without having to return it.

However, in my experience, having been bitten way too many times by not paying attention to scopes and mis-using "global variables", in my humble opinion, it is much, much better to be careful and discipline oneself to think of it more along the lines as raybies posed it by keeping things more encapsulated and planning for the variable to be local to the subroutine and then explicitly returning values that you want to change...or to at least be clearer, through the use of references as some of the other responders suggested, that you are doing the change.

But that is just my opinion and certainly your comment is, to the best of my knowledge, right.

ack Albuquerque, NM

In reply to Re^3: Bit operation by ack
in thread Bit operation by toren

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 admiring the Monastery: (7)
As of 2024-04-23 18:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found