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

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

By your logic, the following never deallocates the referenced array:

use Devel::Peek;
$x = []; Dump($x, 1);
$x = undef;$x = [];
Dump(\$x, 1);
[download]
SV = IV(0x51a420) at 0x51a424
REFCNT = 1
FLAGS = (ROK)
RV = 0x61b29c
SV = PVAV(0x61c248) at 0x61b29c
REFCNT = 1
FLAGS = ()
ARRAY = 0x0
FILL = -1
MAX = -1
ARYLEN = 0x0
FLAGS = (REAL)
SV = IV(0x51a420) at 0x51a424
REFCNT = 1
FLAGS = (ROK)
RV = 0x61b29c
SV = PVAV(0x61c248) at 0x61b29c
REFCNT = 1
FLAGS = ()
ARRAY = 0x0
FILL = -1
MAX = -1
ARYLEN = 0x0
FLAGS = (REAL)
[download]

But that's just not true. It just got reallocated at the same address. Looking at the address is not meaningful.

(I'm not saying that it isn't the same scalar. I'm saying you haven't shown that it is the same scalar.)

Replies are listed 'Best First'.
Re^3: lexicals are all the same scalar and never go out of scope?
by Eliya (Vicar) on Dec 06, 2011 at 10:32 UTC
By your logic, the following never deallocates the referenced array: ...

This isn't even remotely what I said.  I said the scalar (i.e. the SV, what you call TARG) is the same, and a copy of it is created when a reference to it is pushed onto the array — nothing more.  That's in essence the same you pointed out in your reply.

I said the scalar (i.e. the SV, what you call TARG) is the same,

You also posted a code snippet and its output. With no explanation, the implication is that it supports the accompanying claim. And it does no such thing.

Reaching the correct conclusion doesn't make how you reached it correct.

Create A New User
Node Status?
node history
Node Type: note [id://941981]
help
Chatterbox?
 [Corion]: Option a) would mean launching cmd.exe /k c:\path\to\ batchfile- launching-perl- script.cmd. Option b) would be to add pause as the last line of said batch file. [LanX]: First day after holidays ... and already stressed by the fact that colleagues changed stuff without communication ... apparently I'm the only one trying to fight entropy [Corion]: LanX: The command is always in the history if you typed it in before. If you didn't type the command into the command line, it will not be there. I think there is doskey which can stuff command lines into the history LanX damns the cult of CB ;-) LanX WTF WTF WTF [LanX]: please forget my last 3 posts [LanX]: Yeah option a doesn't go into history [LanX]: probably I need to teach the app to restart after C-c Kill [Corion]: LanX: Maybe have an infinite-loop cmd file? Much easier than trying to manage that from within Perl IMO [Corion]: Alternatively, relaunch the application from cron (or a Windows cron) every minute

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (12)
As of 2017-03-27 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Should Pluto Get Its Planethood Back?

Results (320 votes). Check out past polls.