Geez! How many hints do you need?

The "If the last statement is a loop control structure..." restriction comes from here:

  • Like many languages, Perl provides for user-defined subroutines.
  • These may be located anywhere in the main program.
  • Loaded in from other files via the do, require, or use keywords.
  • Any arguments passed in show up in the array @_.
  • A return statement may be used to exit a subroutine.
  • If no return is found and if the last statement is an expression, its value is returned.
  • If the last statement is a loop control structure like a foreach or a while , the returned value is unspecified.
  • Subroutines can return Scalar, Array or Hash.

It is only applied to the "last statement of a subroutine". Not to the last statement of a do block?

For counterpoint, not a millions lines away from where that quote comes from, there is another, rather more applicable quote:

The return value of any block, including those used in subroutines, is taken as the value of the last evaluated expression.

And I'm pretty damn confident that I could find numerous examples of you using, and recommending the use, of the return value from a block.

Does this look familiar:

eval { ...; 1; } or ...;

But suddenly, you read a bit of the documentation, apply it to the wrong circumstance, assume that your misinterpretation is the only interpretation.

I seem to recall that someone fairly authoritative suggested that when the documentation is inadequate or in conflict -- as with those two quotes -- the reference specification is the implementation.

So, jump up and down all you like, you're still drawing the wrong conclusion, and I'm bored with watching you do so. So just stop.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^11: Short-circuiting a map list. (This works! But ...) by BrowserUk
in thread Short-circuiting a map list. by BrowserUk

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.