in reply to Re^4: Don't treat your numbers as strings, or Interpolation is worse than you might think
in thread Don't treat your numbers as strings, or Interpolation is worse than you might think

Why does it reverse it to an IV.
It doesn't - it just clears the pPOK flag:

perl -MDevel::Peek -e '$x = 3; "$x"; $x += 0; print Dump $x' SV = PVIV(0x814e998) at 0x814d4ac REFCNT = 1 FLAGS = (IOK,pIOK) IV = 3 PV = 0x8162f50 "3"\0 CUR = 1 LEN = 4
  • Comment on Re^5: Don't treat your numbers as strings, or Interpolation is worse than you might think
  • Download Code

Replies are listed 'Best First'.
Re^6: Don't treat your numbers as strings, or Interpolation is worse than you might think
by Ieronim (Friar) on Jul 23, 2006 at 16:43 UTC
    The effect of removing this flag is very interesting—the value of the string stored in the variable is not deleted, but is "considered" incorrect and is not copied to new variables :)
    perl -MDevel::Peek -e'$x = 3; qq($x); $x+=1; Dump $x; $y=$x; Dump $y' SV = PVIV(0x15d75f4) at 0x15d57e4 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 4 PV = 0x1a53acc "3"\0 CUR = 1 LEN = 2 SV = PVIV(0x15d7604) at 0x15d64d4 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 4 PV = 0
    You see—the PV (value of the string) for $x was not updated by the numeric operation and was not copied to $y. So, being strict, the variables after numification become not pure IV, but PVIV storing only integer, looking much like simple IV, which causes much less work to copy :)

         s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print