How can I call another subroutine from existing subroutine just after the return statement in perl. I dont want to call before the return statement as it is taking time to render. I do not want to wait. return it and then call another subroutine before the exit. Is it possible in perl?
You can fork
and run your subroutine in a new process while the original process is returning.
sub do_something {
my ($var1, $var2, $var3) = @_;
my $output = ...
if (fork() == 0) {
# child process
do_something_else_that_takes_a_long_time();
exit;
}
# still the parent process
return $output;
}