in reply to Re: How to use alarm?
in thread How to use alarm?

It's because that example is using die (vs. print) and the way die needs \n to avoid printing $! (which will affect the comparison against that die message later in that example).

The OPs problem is just buffering. Either

$| = 1; $SIG{ALRM} = sub {print "checking"};
or
$SIG{ALRM} = sub {print "checking\n"};
fixes his problem.

Replies are listed 'Best First'.
Re^3: How to use alarm?
by Fletch (Bishop) on Jul 26, 2008 at 03:06 UTC

    A last argument to die ending in something other than \n prints the file and line where the die was called, not $!.</pedant>

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      I wouldn't call that pedantry: thinking the die message includes the value of $! by default is a serious misunderstanding of die, in disagreement of the "best practice" to include $! in the error message yourself.
      <pedant>You forgot to open your pedant tag.</pedant>

        I personally believe that you should know that the reason why is that Fletch is so pedant that he opened it when you were still wearing diapers, you pedantry-n00b! ;)</humour>

        --
        If you can't understand the incipit, then please check the IPB Campaign.
      <mea_culpa> Indeed. Shoulda re-read the doc before punching 'create'. </mea_culpa>

      Long week.