Yep, your example shows what I'm talking about :-) Remember Perl's special false value will look like both the empty string and the number zero at the same time (it's basically a dualvar), in your YAML it's showing up as its string version. To identify Perl's special false value, you actually have to look a tiny bit into the internals. The first example below shows that in list context, a failed match is returning the empty list (which in a hash translates to undef; add -w to your first example and you get Odd number of elements in anonymous hash). The second example shows that forcing scalar context on the match causes it to return Perl's special false value.

$ perl -MDevel::Peek -le 'my @x = /abc/; Dump(@x)' SV = PVAV(0x51f85b346e78) at 0x51f85b3c66b8 REFCNT = 1 FLAGS = () ARRAY = 0x0 FILL = -1 MAX = -1 FLAGS = (REAL) $ perl -MDevel::Peek -le 'my @x = scalar(/abc/); Dump(@x)' SV = PVAV(0x579bb31a2e38) at 0x579bb31c86a8 REFCNT = 1 FLAGS = () ARRAY = 0x563bc3d01720 FILL = 0 MAX = 3 FLAGS = (REAL) Elt No. 0 SV = PVNV(0x579bb31a1f40) at 0x579bb31a15a8 REFCNT = 1 FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK) IV = 0 NV = 0 PV = 0x579bb31cd6e4 ""\0 CUR = 0 LEN = 10

In reply to Re^5: Bug in Class::Struct? by haukex
in thread Bug in Class::Struct? by freonpsandoz

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.