in reply to Re: "next" from within eval {} ?
in thread "next" from within eval {} ?

In the real code there's further things being done in between the do_*() calls (computations depending on the return values of the functions etc.). So I'm not sure if chaining the calls with && would make it any clearer. (I've heavily simplified the code not to distract too much from my actual question about the reasoning behind the warning.)

I just thought that putting one eval around that entire code block would save me from having to clutter up the code with multiple evals with separate identical "catch" clauses. etc., but the warning made me wonder if there's anything wrong with it...

Thanks.

Replies are listed 'Best First'.
Re^3: "next" from within eval {} ?
by BrowserUk (Patriarch) on Dec 15, 2011 at 17:12 UTC

    Fair enough. T'was nought but a thought :)

    Funnily enough, I don't get the warning on 5.10.

    #! perl -slw use strict; sub do_foo { $_ != 3 or die "foo == 3" } sub do_bar { $_ != 4 or die "bar == 4" } for (1..5) { eval { next unless do_foo(); next unless do_bar(); #... 1; } or do { warn $@; next; }; print; } __END__ c:\test>junk47 1 2 foo == 3 at C:\test\junk47.pl line 4. bar == 4 at C:\test\junk47.pl line 5. 5

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    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.

    The start of some sanity?

      "Funnily enough, I don't get the warning on 5.10."

      I think the next has to actually "execute" to generate the warning. In your modified version, the functions die instead of returning false (only the latter would trigger the execution of the next).

      I do get the warning with all versions I've tested (5.10.0, 5.10.1, 5.12.3, 5.14.1).

        Of course.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        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.

        The start of some sanity?