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

I’ve been reading about the Progress::Any module and would like to make use of it, but after reading the documentation I’m having trouble figuring out if it can do exactly what I want. So far I have something like this in the subroutine that needs to report status:
use Progress::Any; my $progress = Progress::Any -> get_indicator( task => ‘work’ ); # Do some stuff $progress -> update( message => “I did some stuff” ); # Do some more stuff $progress -> update( message => “I did some more stuff”);
Now, is it possible to get those messages and assign their content to a variable in the calling program, rather than printing them to the command line? A little more detail: My application forks, and the child process calls a long-running sub (the one that contains the code above) while the parent process monitors its status. I want the parent process to be able to retrieve the messages from the child’s sub, rather than having those messages go to STDOUT or wherever they normally go. Thanks for any advice!

Replies are listed 'Best First'.
Re: Can I use Progress::Any to monitor a child process?
by Anonymous Monk on Aug 07, 2015 at 01:34 UTC

    Sure , probably, see IPC::Run3

    smart quotes dont work, use regular '' and ""

Re: Can I use Progress::Any to monitor a child process?
by Monk::Thomas (Friar) on Aug 07, 2015 at 13:12 UTC

    Your description sounds very suspicious to me. How are you going to access the variable in the parent process?

    fork

    Does a fork(2) system call to create a new process running the same program at the same point. It returns the child pid to the parent process, 0 to the child process, or undef if the fork is unsuccessful. File descriptors (and sometimes locks on those descriptors) are shared, while everything else is copied.
    -- http://perldoc.perl.org/functions/fork.html

    Or am I misunderstanding and you do not want to access a child's variable from the parent?