I have a site running Dancer.
In this site, i have a form with one textarea, and foreach line written in this textarea, when the form is submitted via post, i do some action for it. Each line starts a process, and it takes some time ( depending of the line, the process can take about 20 secs, 40 secs, 1 minute... )
The post is something like this:
post '/actions/AddSrv' => sub {
my $self = shift;
my @Results;
foreach my $dest_addr ( split /\n/, params->{HostsList} ){
#Here starts the process
my $Result = start_some_process($dest_addr);
push @Results, $Result;
##Now i have the result of this process execution
}
template 'actions/AddSrv.tt', { Results => [ @Results ] }, { layout => 'logged_site' };
};
with this code, I need to wait until all $dest_addr are processed to view in the screen the result of all executions. Exists a way to print inmediatly the result of each process when the call to start_some_process() ends? Now I need to wait until the foreach ends, to return the template
How can I achieve something like this?