IV - holds signed int, unsigned int or ref NV - holds float PV - holds string

And then there are fields to support magic lvalues and general magic.

Not every field is available at all times. SVs (scalars) have a head which contains a pointer to the body. The body is automatically upgraded when needed (e.g. my $x = 1; $x += 0.1;, tie my $x, ..., etc).

And even if the field is available, not all values are available at all times. Flags indicate which fields are initialised and what they contain.

$ perl -MDevel::Peek -e' my $x; Dump $x; $x = 123; Dump $x; "$x"; Dump $x; ++$x; Dump $x; $x=undef; Dump $x; ' Fresh var, no body, no content: SV = NULL(0x0) at 0x88c6920 REFCNT = 1 FLAGS = (PADMY) After assigning int, body upgraded to IV (has field IV), and IV field contains a number (IOK): SV = IV(0x88c691c) at 0x88c6920 REFCNT = 1 FLAGS = (PADMY,IOK,pIOK) IV = 123 After using content as string, body upgraded to PVIV (has fields IV and PV), IV field contains a number (IOK), and PV field contains a string (POK): SV = PVIV(0x88c56ac) at 0x88c6920 REFCNT = 1 FLAGS = (PADMY,IOK,POK,pIOK,pPOK) IV = 123 PV = 0x88e7710 "123"\0 CUR = 3 LEN = 4 After using content as a number, IV field contains a number (IOK), and PV field isn't being used (!POK): SV = PVIV(0x88c56ac) at 0x88c6920 REFCNT = 1 FLAGS = (PADMY,IOK,pIOK) IV = 124 PV = 0x88e7710 "123"\0 CUR = 3 LEN = 4 After clearing the contents, IV field isn't being used (!IOK), and PV field isn't being used (!POK): SV = PVIV(0x88c56ac) at 0x88c6920 REFCNT = 1 FLAGS = (PADMY) IV = 124 PV = 0x88e7710 "123"\0 CUR = 3 LEN = 4

In reply to Re^5: Booleans from flip-flops by ikegami
in thread Booleans from flip-flops by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.