$ date; perl -wMstrict -le '$a=time;$SIG{ALRM}=sub{$b=time};alarm 2;<>;print $b-$a'; date Sat Jul 21 05:59:28 AEST 2018 ^C $