There are many different types of scalars.
- SvNULL cannot contain any value except undef.
- SvIV is capable of retaining IV, UV, or RV.
- SvNV is capable of supporting NV.
- SvPV is able to retain PV.
- SvPVIV is capable of retaining PV as well as IV, UV or RV.
- ...
AV, HV, CV, GV are really just types of scalars.
. , "" . , - . .
.
SvIV ( , IV) , SvPV ( , PV).
$ perl -le'
use Devel::Size qw( total_size );
use Inline C => <<'\''__EOI__'\'';
void upgrade_to_iv(SV* sv) {
SvUPGRADE(sv, SVt_IV);
}
void upgrade_to_pv(SV* sv) {
SvUPGRADE(sv, SVt_PV);
}
__EOI__
{ my $x; upgrade_to_iv($x); print total_size($x); }
{ my $x; upgrade_to_pv($x); print total_size($x); }
'
24
40
SvIV SvPV - 16 .