I have two pieces of code below. The first alarm works perfectly using sleep. However the second alarm does not trigger. Any idea's how to resolve the second piece of code where the gethostbyaddr won't trigger the alarm?

Code

use strict; use warnings; use Net::IP; use Net::DNS; use Socket qw( AF_INET inet_aton );

Apologies. I've now amended the code and also added in a workaround which works significantly faster than gethostbyaddr. Although issue is solved, it would still be interesting to know why the alarm does not work on the second piece of code and whether there is another way to implement an alarm for functions similar to gethostbyaddr.