Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How does 'goto LABEL' search for its label?

by Anonymous Monk
on Jan 16, 2013 at 15:32 UTC ( #1013589=note: print w/replies, xml ) Need Help??


in reply to How does 'goto LABEL' search for its label?

goto says (among other things)

Use of "goto-LABEL" or "goto-EXPR" to jump into a construct is deprecated and will issue a warning. Even then, it may not be used to go into any construct that requires initialization, such as a subroutine or a "foreach" loop. It also can't be used to go into a construct that is optimized away.

So LABELs are like lexicals, except with only file-scope or subroutine-scope ( Lexical scoping like a fox )

lexical(my) variables from one loop/block is not visible in another, but labels are , because they currently have file scope (like my $foo at the top of a file outside of any bare blocks)

currently { L: say 1; } is like my $L; { $L=1; say $L; }

But this will change, once  Use of "goto" to jump into a construct is deprecated   is disallowed, labels will be lexically scoped like my $vars

someday { L: say 1; } is like { my $L=1; say $L; }

Replies are listed 'Best First'.
Re^2: How does 'goto LABEL' search for its label?
by Anonymous Monk on Jan 16, 2013 at 17:28 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013589]
help
Chatterbox?
[nysus]: What happened to the submit button? All I have is a preview button.
[erix]: perlmonks has become read-only ?
[marto]: erix unlikely, we've had posts within the last few minutes ;)
[ambrus]: nysus: make sure you enter at least two lines for the title and then preview, and read warnings the preview form prints
[davies]: There is an option (I have it set) to force preview before submission. Perhaps your option has been set (accidentally?) and you are not expecting it.
[ambrus]: sorry, I mean at least two words for the title and then preview
[ambrus]: davies: that option is the default. and it's not really "force", it just hides the button.
[marto]: yes, not reading the errors displayed has been a cause of this type of report in the past
[nysus]: Ambrus, ah. I think that was the problem. I'll try. Thanks!

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (14)
As of 2017-12-15 11:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (431 votes). Check out past polls.

    Notices?