http://www.perlmonks.org?node_id=1011865


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.