#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11111522 use warnings; # borrowed from choroba use feature qw{ say }; local $SIG{USR1} = sub { say STDERR "Signal 1 caught."; }; local $SIG{USR2} = sub { say STDERR "Bye!"; exit }; my $sum = 0; while (1) { $sum += $_ for 1 .. 100; say $sum; say STDERR scalar localtime, " Sleeping..."; select undef, undef, undef, 10; say STDERR scalar localtime, " Ready!"; }