#!/usr/bin/perl use 5.016; use warnings; use strict; my $prev_ctrlc = 0; if( ($prev_ctrlc == 0) || ($prev_ctrlc == 1) ) { $SIG{'INT'} = \&control_c_observed; sleep 1; for (1..1e3) { say "\t nothing yet"; sleep 2; } } sub control_c_observed { if ($prev_ctrlc == 0) { print "Second ctrl-c within 2 seconds required\n"; $prev_ctrlc = 1; } else { $prev_ctrlc++; } if ($prev_ctrlc == 2 ) { say "OK, that's two of 'em!"; exit; } } #### C:\>C:\SQLite\1018190.pl nothing yet nothing yet nothing yet # single tap here Second ctrl-c within 2 seconds required nothing yet nothing yet # double tap here OK, that's two of 'em! C:\>