Hey Mongers!

Goggling around, I could not determine whether or not Perl LABELs are
subject to the usual lexical scoping rules as are "my" declared variables. I
almost always label "for"/"foreach"/"while" etc. blocks so it should be
clear where will "next"/"last"/"redo" go. And sometimes the natural name for
the loop is the same, e.g., "EMPLOYEE:".  So I wonder if I can reuse the
same label if it is clearly in a different scope.

Simple tests were successful, but I would like to have a more authoritative
answer. The closest I came to finding any reference to the issue is in
<http://perldoc.perl.org/perlsyn.html#Goto> "perlsyn" GOTO:

The goto <http://perldoc.perl.org/functions/goto.html> -EXPR form expects a
label name, whose scope will be resolved dynamically. This allows for
computed goto <http://perldoc.perl.org/functions/goto.html> s per FORTRAN,
but isn't necessarily recommended if you're optimizing for maintainability:

1.      goto <http://perldoc.perl.org/functions/goto.html> (("FOO", "BAR",
"GLARCH")[$i]);

But although this does suggest  a scope for a label, it does not answer IMHO
my question beyond doubt.

Can anybody elucidate?

Regards,
Meir

 

_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl

Reply via email to