$ perl -MDP -wE'DDump Data::Peek::triplevar"\x{03c0}",3,3.14159265'
SV = PVNV(0x8760c9c) at 0x817d0a4
REFCNT = 1
FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK,UTF8)
IV = 3
NV = 3.14159265
PV = 0x818bdf0 "\317\200"\0 [UTF8 "\x{3c0}"]
CUR = 2
LEN = 12
$
With Data::Peek's DDual () you can get all parts seperate into different scalars:
$ perl -MDP -wE'DPeek for DDual Data::Peek::triplevar"\x{03c0}",3,3.14
+159265'
PV("\317\200"\0) [UTF8 "\x{3c0}"]
IV(3)
NV(3.14159)
SV_UNDEF
IV(0)
FWIW \x{03c0} is the Unicode representation for π (\N{GREEK SMALL LETTER PI} when using use charnames;)
Enjoy, Have FUN! H.Merijn
| [reply] [d/l] [select] |
use 5.010; # just for "say"
use B;
($f,$g)=(333,"xyz");
say ref B::svref_2object(\$f);
say ref B::svref_2object(\$g);
edit
Devel::Peek might also help you. | [reply] [d/l] |
use feature qw( say );
use B qw( );
my ($f,$g) = (333,"xyz");
say B::class(B::svref_2object(\$f));
say B::class(B::svref_2object(\$g));
IV
PV
Note that this returns the SV *type*. It can return "PV" even if the scalar has no PV.
use feature qw( say );
use B qw( );
$_ = 333;
"".$_;
$_ = undef;
say B::class(B::svref_2object(\$_));
PVIV
This is what the OP asked, but he probably wants to know what the scalar *has*.
| [reply] [d/l] [select] |
Are you asking what the SV is (NULL, BIND, IV, NV, PV, PVIV, PVNV, PVMG, REGEXP, PVGV, PVLV, PVAV, PVHV, PVCV, PVFM, PVIO), what fields the SV has (IV, NV, PV, GP, etc) or which value is present in the SV (IV, UV, NV, PV, RV, GP, private IV, private NV, private PV, etc)?
For example,
$ perl -MDevel::Peek -E'$_ = 2**31; ++$_; say "value: $_"; Dump $_;'
value: 2147483649
SV = PVNV(0x8cc0ac8) at 0x8cebef8
REFCNT = 1
FLAGS = (IOK,POK,pIOK,pPOK,IsUV)
UV = 2147483649
NV = 2147483648
PV = 0x8cdf378 "2147483649"\0
CUR = 10
LEN = 12
$_ is a PVNV. It has fields IV*, NV and PV. It has UV and PV values.
I find the last most likely. If so, asking the question is surely due to a bad design decision. A PV, IV, UV and NV of twenty should all be considered the same value. That's why Perl doesn't provide an interface to provide that information in core (although it's trivial for an XS module to access that information).
* — It's called "IV", but Devel::Peek printed "UV" because it currently contains a UV.
| [reply] [d/l] [select] |
| [reply] |