in reply to coming out of perl script after 10 min.
alarm sounds like the right approach here. So you need to show your code (reduced to the relevant part) here, otherwise we can't know what's wrong with it.
See also: How (Not) To Ask A Question
In Section
Seekers of Perl Wisdom