This script creates a variable that's a Math::BigInt object, and then changes that variable into a normal integer value:
use warnings;
use strict;
use Math::BigInt;
use Devel::Peek;
my $x = Math::BigInt->new(42);
Dump $x; # Shows that $x is a
# Math::BigInt object
print "\n ########\n ########\n\n";
$x = "$x" + 0;
Dump $x; # Shows that $x is
# a normal integer
That's my answer to the question that I'm guessing you want answered.
That script outputs:
SV = PV(0x2ee308) at 0x3481a0
REFCNT = 1
FLAGS = (ROK)
RV = 0x2ed750
SV = PVHV(0x32d528) at 0x2ed750
REFCNT = 1
FLAGS = (OBJECT,SHAREKEYS)
STASH = 0x350118 "Math::BigInt
ARRAY = 0x334b38 (0:6, 1:2)
hash quality = 125.0%
KEYS = 2
FILL = 2
MAX = 7
Elt "sign" HASH = 0x46c14520
SV = PV(0x2ee298) at 0x33dd58
REFCNT = 1
FLAGS = (POK,IsCOW,pPOK)
PV = 0x24f9288 "+"\0
CUR = 1
LEN = 10
COW_REFCNT = 1
Elt "value" HASH = 0xaea09fe1
SV = IV(0x33de38) at 0x33de48
REFCNT = 1
FLAGS = (ROK)
RV = 0x33dda0
SV = PVAV(0x2ef240) at 0x33dda0
REFCNT = 1
FLAGS = ()
ARRAY = 0x2871cc8
FILL = 0
MAX = 0
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = IV(0x33dd78) at 0x33dd88
REFCNT = 1
FLAGS = (IOK,pIOK)
IV = 42
PV = 0x2ed750 ""
CUR = 0
LEN = 0
########
########
SV = PVIV(0x346738) at 0x3481a0
REFCNT = 1
FLAGS = (IOK,pIOK)
IV = 42
PV = 0
Only caveat I can spot is that if $x had been created as my $x = 42; then the PV slot would not have been set at all (on perl-5.24.0, anyway).
Cheers,
Rob |