So, the wantarray is used "at the top of the file", but it seems that wantarray is working fine. Can we rely on it?

No, we can't. That's exactly what the docs are saying, unequivocally. They say that this behavior is unspecified, i.e. "don't rely on it". The fact that it appears to work in your example does not in any way contradict this.

Let me give you another example, one that came up in a recent thread. The docs for undef clearly state (my emphasis)

undef EXPR
undef
Undefines the value of EXPR, which must be an lvalue. Use only on a scalar value, an array (using @), a hash (using %), a subroutine (using &), or a typeglob (using *).
Now, if I try this on v5.8.6:
undef @h{ 1, 2 };
it appears to work (i.e. $h{ 1 } and $h{ 2 } get set to undef). Still this code is using unspecified/undocumented behavior, because it is applying undef to a list, which is none of the documented valid arguments for undef. Hence, according to the docs, such code is liable to break in the future, and it would be considered a bad practice to use such code, that it appears to work notwithstanding.

the lowliest monk


In reply to Re^3: wantarray documentation in 5.8.7 by tlm
in thread wantarray documentation in 5.8.7 by polettix

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.