use Devel::Size qw(size); use Devel::Peek; sub info { print Dump($_[0]); print "size = ",size($_[0])," ($_[1])\n\n"; } $num = 123; # or int("123") info($num, "integer"); $num .= ""; info($num, "integer stringified"); $str = "123"; info($str, "string"); $str += 0; info($str, "string numified"); $str += 45678900; info($str, "... with bigger integer"); $str .= ""; info($str, "... re-stringified"); #### SV = IV(0x816983c) at 0x8192124 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 123 size = 16 (integer) SV = PVIV(0x8150b10) at 0x8192124 REFCNT = 1 FLAGS = (POK,pPOK) IV = 123 PV = 0x81c9f18 "123"\0 CUR = 3 LEN = 4 size = 32 (integer stringified) SV = PV(0x814fb90) at 0x81ca934 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x81950f0 "123"\0 CUR = 3 LEN = 4 size = 28 (string) SV = PVIV(0x8150b20) at 0x81ca934 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 123 PV = 0x81950f0 "123"\0 CUR = 3 LEN = 4 size = 32 (string numified) SV = PVIV(0x8150b20) at 0x81ca934 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 45679023 PV = 0x81950f0 "123"\0 CUR = 3 LEN = 4 size = 32 (... with bigger integer) SV = PVIV(0x8150b20) at 0x81ca934 REFCNT = 1 FLAGS = (POK,pPOK) IV = 45679023 PV = 0x81950f0 "45679023"\0 CUR = 8 LEN = 12 size = 40 (... re-stringified)