I don't really know how to explain ["next" cannot be used to exit a block which returns a value such as "eval {}", "sub {}" or "do {}"...]
It means next, last and redo ignore do blocks, eval blocks, etc. They will only cause loop blocks and bare blocks to repeat, exit, etc. It makes more sense when you read that same line in the documentation for last, since next doesn't cause a loop to exit.
foreach my $var (1, 2, 3, "skip", 4) {
eval { # This block is ignored.
if ($var eq "skip") {
next;
}
};
print $var;
}
print("\n");
foreach my $var (1, 2, 3, "skip", 4) {
{ # This block exits.
if ($var eq "skip") {
next;
}
}
print $var;
}
print("\n");
outputs
1234
123skip4
|