Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: using the feature 'switch' in loops

by Anonymous Monk
on Jul 30, 2014 at 17:01 UTC ( [id://1095636]=note: print w/replies, xml ) Need Help??


in reply to Re^2: using the feature 'switch' in loops
in thread using the feature 'switch' in loops

You're correct about the documentation, at least for Perl v5.16 and up (in which the entire given/when/smartmatch feature is "experimental"), and Switch statements could mention the behaviour of last within a given for clarity.

But last without a label always breaks out of the innermost loop, so I still don't find that behaviour surprising and your observation that "the 'last' statement in the switch statements controlled the flow within the switch statement" is not quite right, since in your examples you're not inside a "switch" (given), you're inside two for loops.

The only argument one might make is that that behaviour is inconsistent and last should also break out of a given (but according to your original post you don't expect that behaviour).

I don't understand what you mean about a "masked loop statement". Switch is deprecated and has nothing to do with Switch statements (given/when) except the shared name of the feature.

Replies are listed 'Best First'.
Re^4: using the feature 'switch' in loops
by Anonymous Monk on Jul 30, 2014 at 17:21 UTC

    After further reading I would agree that Switch Statements seems to imply that for is a "switch" statement, white actually a for used in this way is still just a for.

    P5P is always happy about doc patches :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-03-19 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found