The refcount isn't changed, even though a variable is read from a forked process. And why should it? I see no need for that.use Devel::Peek; my $x = 3; Dump $x; fork; Dump $x; __END__ SV = IV(0x90e54bc) at 0x90ca648 REFCNT = 1 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 3 SV = IV(0x90e54bc) at 0x90ca648 REFCNT = 1 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 3 SV = IV(0x90e54bc) at 0x90ca648 REFCNT = 1 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 3
The matter is different when variables go out of scope: then their refcount is reduced, thus possibly modifying it before deallocating.
Update It's probably this you meant:
use Devel::Peek; my $x = 3; Dump $x; my $y = \$x; Dump $x; __END__ SV = IV(0x97634bc) at 0x9748648 REFCNT = 1 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 3 SV = IV(0x97634bc) at 0x9748648 REFCNT = 2 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 3
In reply to Re^2: WHY copying does happen (fork)
by moritz
in thread WHY copying does happen (fork)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |