Timeout....

val {
    local $SIG{ALRM} = sub { die "alarm timeout" };
    local $SIG{__DIE__} = sub { alarm 0; die @_ };
    alarm $timeout;
    # operation you're waiting on which might die()
    # in the grandparent post, this was 
    # $line=<$child>
    alarm 0;        # cancel the alarm
};
die $@ if $@ && $@ !~ /alarm timeout/;
if ($@) {
    # Whatever you want on an alarm timeout
}

( from perlmonks post by fizbin ):w

| Timeout.... | | 2004.03.09-13:32.00

 You are scrupulously honest, frank, and straightforward. Therefore you have few friends.