Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Wait ... Loading ... message in Perl/CGI

by convenientstore (Pilgrim)
on Jan 26, 2008 at 04:01 UTC ( [id://664426]=note: print w/replies, xml ) Need Help??


in reply to Re: Wait ... Loading ... message in Perl/CGI
in thread Wait ... Loading ... message in Perl/CGI

I have always wanted to do this on regular script (none html)
can someone please let me know how to do this the right way?
my incorrect version is
use strict; sub clear_screen { system("clear"); print "wait......................\n"; } sub doit { my $yahoo; while ($yahoo < 100) { clear_screen(); $yahoo++; } print "\$yahoo is $yahoo\n"; } doit();

Replies are listed 'Best First'.
Re^3: Wait ... Loading ... message in Perl/CGI
by pc88mxer (Vicar) on Jan 26, 2008 at 06:14 UTC
    You have to learn about fork-ing and managing child processes. Here's some example code:

    use POSIX qw(:sys_wait_h); sub doit { my $pid = fork(); unless (defined($pid)) { die "unable to fork: $!\n"; } if ($pid) { # parent # wait for child to finish and display waiting message my $start = time; while (1) { print "time spent waiting: ", time - $start, "\n"; last if (waitpid($pid, WNOHANG) > 0); sleep(2); } # child process has terminated # read results from file open(R, "<results-from-child-process"); while (<R>) { ... process results... }; close(R); } else { # child # perform time consuming computation here. ... # leave results in some file open(R, ">results-from-child-process"); print R ...; close(R); exit(0); } }
      thanks~ going to try this today and get back to you.
Re^3: Wait ... Loading ... message in Perl/CGI
by Joost (Canon) on Jan 26, 2008 at 12:59 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://664426]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found