Leser: 11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
my ( $confirm, $skip ) = ( ' Confirm', ' Skip' ); my $tc = Term::Choose.new(); my $choice; my $timeout = Promise.in( 50 ).then({ $choice = $confirm; $tc.end-term(); # 1 $tc.reset-term(); # 2 $tc.restore-term(); # 3 }); my $code = start { $choice = $tc.choose( ( Str, $confirm, $skip ), :undef( ' Exit' ) ); } await Promise.anyof( $timeout, $code ); if ! $choice.defined { ... } elsif $choice eq $confirm { ... } elsif $choice eq $skip { ... }