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??

First, you keep talking about my and lexical vars, but the only two lexical vars are $count and @savearr, but your question has nothing to do with either. I have no idea why you keep mentioning them. Of course, that means your ultimate question makes no sense.

Second, your references are to different scalars. As you said, how else can they have different values as shown in the dump.

So on to the interesting bit, what is it you're making read-only, and why does it have that effect.

Each instance of the concatenation operator has a scalar called "TARG" associated with it. The concatenation operator concatenates its operands into its TARG, and it returns its TARG. This is an optimisation, as it saves the operator from making a new scalar every time it's called. You made that scalar read-only, messing with the concatenation operator's ability to change it the next time it is called.

So how come you end up with references to different scalars? The dereference operator must know something is special about the scalar*, makes a copy of it, and returns a reference to the copy.

* — I was hoping to provide more details about this, but I've run out of time. I'm guessing it's based on the presence of the PADTMP flag.


In reply to Re: lexicals are all the same scalar and never go out of scope? by ikegami
in thread lexicals are all the same scalar and never go out of scope? by patcat88

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (12)
    As of 2014-12-20 14:30 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

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





      Results (96 votes), past polls