Skip to content

Instantly share code, notes, and snippets.

@cygx
Forked from awwaiid/catch-control.p6
Last active August 24, 2016 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cygx/7efc3f49089c7eb3b61ac2e8c500b81c to your computer and use it in GitHub Desktop.
Save cygx/7efc3f49089c7eb3b61ac2e8c500b81c to your computer and use it in GitHub Desktop.
sub catch-control {
my $the-answer = 42;
CONTROL {
die "Caught a CONTROL ({.gist})";
}
die "forced exception";
say "resumed!";
}
for 1 {
catch-control;
CATCH {
say "EXCEPTION: {$_.gist}";
say "the answer is " ~ CALLER::CALLER::CALLER::CALLER::MY::<$the-answer>;
.resume;
last;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment