Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^5: Short-circuiting a map list. (This works! But ...)

by BrowserUk (Pope)
on Oct 08, 2011 at 18:29 UTC ( #930376=note: print w/ replies, xml ) Need Help??


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

If the last statement is a loop control structure like a foreach or a while , the returned value is unspecified.

But the bare block is not the last statement.


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.


Comment on Re^5: Short-circuiting a map list. (This works! But ...)
Re^6: Short-circuiting a map list. (This works! But ...)
by ikegami (Pope) on Oct 09, 2011 at 05:18 UTC
    It's not the last statement of the sub, but it is the last statement of the do. What do you think do returns? The value to which the loop evaluates, which isn't defined.
      What do you think do returns?

      I know what the do returns:

      print do{ { print 'fred'; map $_,1 .. 10 } };; fred 1 2 3 4 5 6 7 8 9 10

      The result of the last statement inside the bare block.


      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.

        No. You've already shown it doesn't do that in practice (in Re^3: Short-circuiting a map list. (This works! But ...)), and it doesn't do that according to the documentation.

        A BLOCK by itself (labeled or not) is semantically equivalent to a loop that executes once.

        If the last statement is a loop control structure like a foreach or a while, the returned value is unspecified.

        You just got lucky here.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://930376]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-12-21 18:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls