in reply to Script dieing after arbitrary time

I suspect that this is not enough code to figure out 'why' your sript is dying. I suggest that you try a massive amount logging (constantly flushing your buffer, or use a non buffering logging mechanism) to find out where.

There seems to be an error in you sample code at the point below:

foreach my $name (@names) { if(!name already_in_database()) {

Shouldn't name -> $name ? Additionally, shouldn't it read more like:

if(! already_in_database($name))

Good luck with that!