Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: lexicals are all the same scalar and never go out of scope?

by ikegami (Pope)
on Dec 06, 2011 at 10:08 UTC ( #941985=note: print w/replies, xml ) Need Help??

in reply to lexicals are all the same scalar and never go out of scope?

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://941985]
[oiskuu]: Hm. that depends on kernel compiled with CONFIG_AUDITSYSCAL L
[tye]: apropos my several mentions of audit
[Corion]: At least my (non-SELinux) Debian has that config thing set. I don't have non-Debian machines handy (except Android)
[Corion]: My Android phone also has /proc/self/ loginuid, but that displays -1 (resp. 4GB). That might be because the phone is rooted.

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2017-06-23 19:54 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (554 votes). Check out past polls.