Some perl that sets a timeout value

#!/usr/bin/perl

$SIG{ALRM} = sub { alarmed(); };

alarm(20);
eval { check_whatever; };
alarm(0);

sub check_whatever()
{
  # stuff to do that might timeout
  exit 0;
}

sub alarmed()
{
  # stuff to do after the alarm has gone off.
  exit 1;
}

Thanks to Timbo for help with this…