in reply to Re^7: Changing array by changing $_?
in thread Changing array by changing $_?
>perl -MDevel::Peek -e"Dump('Hello Sailor')" SV = PV(0x228e68) at 0x1831670 REFCNT = 1 FLAGS = (PADBUSY,PADTMP,POK,READONLY,pPOK) ^^^^^^^^ PV = 0x1833f3c "Hello Sailor"\0 CUR = 12 LEN = 16
Obviously that mechanism won't help you here.
In fact, a flag alone won't work since you'd need to know how many times a variable has been aliased to know when to remove the flag. (Upd: I'm not sure about the preceding statement. Can't think straight right now. )
You could add magic to the variable like taint does.
>perl -T -MDevel::Peek -e"Dump($ARGV[0])" foo SV = PVMG(0x1822dcc) at 0x226ba0 REFCNT = 1 FLAGS = (GMG,SMG,pPOK) IV = 0 NV = 0 PV = 0x182d324 "foo"\0 CUR = 3 LEN = 4 MAGIC = 0x182d33c MG_VIRTUAL = &PL_vtbl_taint MG_TYPE = PERL_MAGIC_taint(t) MG_LEN = 1
But now you're getting into costly.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: Changing array by changing $_?
by gone2015 (Deacon) on Oct 13, 2008 at 22:07 UTC |