Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Monks, How are you?
I am having a problem where my program makes a lot of DB connections at once, and display results after all the calls are completely done.
What I am trying to do is display the results as it goes along, how can I stop sequentially my code at some point, make it wait some more, display some more on the screen until it completes it's processing, that way the user doesn't have to wait 15 seconds for the program to get done.
Thanks in advance!

Replies are listed 'Best First'.
Re: Stopping Program
by edan (Curate) on Dec 30, 2004 at 14:11 UTC

    You haven't provided enough detail for us to adequately answer your question.

    What kind of program is it? command-line? CGI? Tk?

    Show some of your code, and explain things a bit more.

    In the simplest case, if it's a command-line program and you are printing to STDOUT as you go, you can fix your buffering problems with a simple $| = 1;

    If it's a CGI program, you might need to look at merlyn's oft-referenced column.

    --
    edan

Re: Stopping Program
by dragonchild (Archbishop) on Dec 30, 2004 at 14:12 UTC
    Your problem is in the statement and display results after all the calls are completely done. It sounds like you want to display the results as they come in. Without seeing your code, I have no way to suggest improvements, but that's the design change you'll want to make.

    One possibility would be use the threads or forking in order to have various actions running at the same time with the parent thread/process monitoring the children and reporting on results when they come in.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.