Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Nice. I've been looking for a solution for a while for resolving this disparity:

use 5.010; use List::Util qw(first); sub sub1 { first { return 1 } @_; return 2; } sub sub2 { grep { return 1 } @_; return 2; } say sub1(0); say sub2(0);

Given that first and grep are conceptually similar, it is counter-intuitive that return inside them means different things. While prototypes help first look like a built-in list operator, they don't help it act like one.

I've played around with Scope::Upper a little to try to come up with a resolution for this, but haven't had any luck so far. (Though as a by-product I managed to come up with returning which is pretty fun.) I wonder if last might provide some kind of solution.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

In reply to Re: Non-local return via last() by tobyink
in thread Non-local return via last() by moritz

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [atcroft]: james28909: No, unless you are a politician, I wouldn't say that (and even if you are, I still probably wouldn't say that).
    [james28909]: i mean how hard can it be? its just subtracting days lol
    [atcroft]: james28909: What about October 5, 1582?
    [stevieb]: atcroft: "Make both hands into fists..."... is something my Ma taught me in our native lang, but I was to ignorant and young to pay attention. Thanks for that :)
    [atcroft]: stevieb: Sad to say that I only recently learned that particular trick, but I have since found it very useful.... :)
    [james28909]: ill be back with a solution eventually
    [stevieb]: it's a reminder to re-inforce it :P
    [atcroft]: james28909: That particular questions was a bit of trick, actually (depending on the country you are in). More interesting is, if you are trying to subtract from an epoch time, for instance, you might have to consider when/if DST occurs for a location,
    [atcroft]: because you may have to adjust the number of seconds you change from an epoch from 86400 (not to mention leap seconds)....

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (3)
    As of 2017-04-29 04:35 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      I'm a fool:











      Results (531 votes). Check out past polls.