tadman has asked for the wisdom of the Perl Monks concerning the following question:

Is there a simple way to find out how a scalar is being stored internally? If I recall correctly, all values used to be stored as strings, but at least in Perl 5, there is a distinction between integer, floating point, and regular string scalars.

For example, how are the following stored:
my @foo = (1, 2.345, "sixseven");
This is kind of a nitty-gritty thing which you're not supposed to care about, right?

Replies are listed 'Best First'.
Re: Scalar Storage Type Discovery
by jmcnamara (Monsignor) on Aug 23, 2002 at 09:07 UTC

    Devel::Peek lets you do this. From the pod:
    use Devel::Peek; $a = 42; Dump $a; The output: SV = IV(0xbc818) REFCNT = 1 FLAGS = (IOK,pIOK) IV = 42

    The PVIV, IV, RV and other types are explained in perlguts.

    For anyone who is interested, there is a good explanation in the Internal Variables section of Simon Cozens Perl 5 Internals.

    --
    John.

      Thanks! That is exactly what I meant. I knew what they were, but not how to get at them without being in XS mode.

      I have this crazy idea that this is somehow connected with my trouble in DBD::mysql Unusual Behavior.