in reply to Re^2: Bit operation
in thread Bit operation
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Bit operation
by jethro (Monsignor) on Jan 12, 2011 at 16:36 UTC |