Created
December 1, 2011 08:50
-
-
Save jhthorsen/1415105 to your computer and use it in GitHub Desktop.
return from inside sub{}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
sub foo { | |
my $res = ''; | |
warn "foo(): @_"; | |
(sub { | |
warn "ANON(): @_"; | |
$res = shift; | |
goto RETURN; | |
})->(@_); | |
warn "this line will be skipped"; | |
RETURN: $res; | |
} | |
warn foo(123); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
could be useful from inside try/catch: