-
Notifications
You must be signed in to change notification settings - Fork 601
Description
On perlsyn, around
The LABEL is optional, and if present, consists of an identifier
followed by a colon. The LABEL identifies the loop for the loop control
statements "next", "last", and "redo".
do say something like "If more than one label with the same name occurs, it
refers to the nearest one above it".
As there is no error in doing e.g., this,
L: while ( $_ = shift @pids ) {
my $c = -1;
L: for my $genre (@genres) {
$c++;
L: if ( $genre->{Exclude} && $$p{$_}{title} =~ /$genre->{Exclude}/i ) {
next;
}
else {
L: for my $match ( @{ $genre->{Matches} } ) {
if ( $$p{$_}{title} =~ /$match/i ) {
push @{ $genre->{Playlists} }, $_;
next L;
}
}
L: for my $match ( @{ $genre->{Matches} } ) {
if ( $$p{$_}{title} =~ /$match/i ) {
push @{ $genre->{Playlists} }, $_;
next L;
}
}
}
}
}
But the document don't say what multiple identical labels are supposed
to do. It only goes on to mention the case of no label at all,
If the LABEL is omitted, the loop control statement refers to the
innermost enclosing loop.
And even cautions,
This may include dynamically looking back your call- stack at run time
to find the LABEL. Such desperate behavior triggers a warning if you
use the "use warnings" pragma or the -w flag.
But still never touches on multiple identical label cases.
"Why would anybody add multiple identical labels, even on the same block
level?"
That's not a concern of me. I'm just saying the document needs to say
what will happen... or errors should be triggered.