Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This is due to the indirect-object syntax, and is a more elaborate variation on [this example](https://stackoverflow.com/a/11695310/4653379).
- The ["indirect object notation"](https://perldoc.perl.org/perlobj.html#Invoking-Class-Methods) allows code
- method Package @args;
- method { $invocant } @args;
- to be used instead of
- Package->method(@args);
- $invocant->method(@args);
- So the "try" and "catch" words don't matter. The interesting bit here is the more involved and extended syntax, with two parts, each in this indirect object notation.
- This means that
- try {
- call_a( 'x' );
- } catch {
- die "ACTUALLY die $_";
- };
- is equivalent to
- (do {
- call_a( 'x' );
- })->try(
- do({
- die("ACTUALLY die $_");
- })->catch();
- );
- which simplifies to
- call_a( 'x' )->try( die("ACTUALLY die $_")->catch() );
- The code is interpreted with valid syntax (!) and it is the _contents of the block after `try` that runs first_ --- so the program dies and never gets to go for the "method" `try`.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement