Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How does next label work?

by LanX (Canon)
on Jan 06, 2013 at 09:49 UTC ( #1011865=note: print w/ replies, xml ) Need Help??


in reply to How does next label work?

Naked blocks are documented as being internally implemented as loops which are only executed once.

next is a loop control which reevaluates the condition, which is false now.

It's no goto, you can only use if for lables just in front of loop-starts, OTOH gotos can jump to any lables in the same scope.

For your purpose better try redo

> perl { print $x++; redo if $x<6; } __END__ 012345
or real gotos

> perl X: { print $x++; goto X if $x<6; } __END__ 012345

Cheers Rolf

UPDATES:

)from perlsyn

Basic BLOCKs A BLOCK by itself (labeled or not) is semantically equivalent t +o a loop that executes once. Thus you can use any of the loop control statements in it to leave or restart the block.


Comment on Re: How does next label work?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-08-29 19:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (287 votes), past polls