'result' is the last block statement { say "2 seconds are over!"; 'result' } { say "2 seconds are over!"; 'result' } . In Perl, semicolons (not newlines) define the ends of most statements.
In this code:
my $timer = Promise.in(2); my $after = $timer.then({ say "2 seconds are over!"; 'result' });
The second line can be rewritten in this way:
my $after = $timer.then( { say "2 seconds are over!"; 'result' } );
This semicolon just ends the statement say "2 seconds are over!" .
Outside the block, this line
say "2 seconds are over!"; 'result';
there are really two operators:
say "2 seconds are over!";
Including several statements on the same line rarely changes their behavior:
my $timer = Promise.in(2); my $after = $timer.then({ say "2 seconds are over!"; 'result' }); say $after.result;
source share