| |||||||||||
| |||||||||||
Monitoring a Perl program Posted by enquirer (enquirer), 9 February 2004 I have a Perl program that takes a long time to run. How can I check up on its progress - I want to know if it has got into an infinite loop or not, or if it's still running just how much longer it's likely to take ![]() Posted by admin (Graham Ellis), 9 February 2004 Big question this one - lots of possible answers and options. For starters, if your program has a big loop that occupies most of the time you might like to put a printf statement in there, output to STDERR rather that STDOUT, and give the loop count, percentage of the way through, or something like that. Here's a code sample: Code:
Few things to note: * $| turns on autoflush mode (so that your carefully added alerts don't just get buffered). * \r is used rather that \n to ensure that each alerts overrights the previous * printf is used to ensure all lines are the same length If you have a loop that goes round "millions" of times, you won't want to print in every loop - follow your print statement with if (++$freq%50 == 0) or something like that - it will print just one line in every 50! This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |