Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Well, I would characterize the reason as having more to do with the fact that passing $a = 2 as an argument causes an alias to $a to be put into @_. Had a copy of $a's value been placed into @_ instead, then subsequently changing $a to 3 would not impact that copy.

print $a = 1, 0+$a, $a = 2, 0+$a, $a = 3, 0+$a; # prints "313233"

The reason that $a = 2 passes an alias is because it is an "lvalue" expression, which just means that you can do previously mentioned things like ( $a = 2 ) = 3. And the reason that lvalue expressions cause aliases to be passed is two-fold: So you can modify arguments via code like $_[0] = 3 in your sub and because it is more efficient than creating a copy.

- tye        


In reply to Re^5: ternary conditional help (alias) by tye
in thread ternary conditional help by opaltoot

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 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? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2022-08-20 05:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?