use feature qw( say ); use Devel::Size qw( total_size ); use Devel::Peek qw( Dump ); my $num = 1000; say total_size($num); Dump($num); say ''; my $packed = pack("w*",$num); say total_size($packed); Dump($packed); #### 24 SV = IV(0x768010) at 0x768018 <-- See SVt_IV image below REFCNT = 1 FLAGS = (PADMY,IOK,pIOK) IV = 1000 <-- 8 bytes 48 SV = PV(0x752f28) at 0x768000 <-- See SVt_PV image below REFCNT = 1 Three more fields than SVt_IV FLAGS = (PADMY,POK,pPOK) PV = 0x7d6520 "\207h"\0 CUR = 2 <-- Even though only 3 are needed, LEN = 8 <-- 8 byte string buffer allocated #### 16 SV = IV(0x51a100) at 0x51a104 <-- See SVt_IV image below REFCNT = 1 FLAGS = (PADMY,IOK,pIOK) IV = 1000 <-- 4 bytes 36 SV = PV(0x5e8cc4) at 0x51a054 <-- See SVt_PV image below REFCNT = 1 Four more fields than SVt_IV FLAGS = (PADMY,POK,pPOK) PV = 0x5b4334 "\207h"\0 CUR = 2 <-- Even though only 3 are needed, LEN = 12 <-- 12 byte string buffer allocated