in reply to Re^6: Multi-threads newbie questions
in thread Multi-threads newbie questions

How would you go about this?

I would avoid fork and threads in the same program--but then on my platform I avoid fork at almost all costs.

On my platform (windows), each thread has it's own current working directory:

c:\test>perl -Mthreads -le"@t = map{ async( sub{ chdir shift;sleep 3;print`cd`} ,$_) } qw[c:\\ c:\\test c:\\test\\_Inline];$_->join for @t" c:\ c:\test c:\test\_Inline

But I seem to remember that doesn't hold true for other platforms.

In any case, I'd simply do:

system "cd $path && theProg @args";

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

Replies are listed 'Best First'.
Re^8: Multi-threads newbie questions
by daverave (Scribe) on Sep 20, 2010 at 16:44 UTC
    I finally went with my $out = capture ([0], "cd $path ; theProg @args");

    the forking gave me so much problems... I have no idea why I started using it.

      Where does capture() come from?

        IPC::System::Simple

        p.s. not sure I understand the difference between the normal and the *x versions (e.g. capture vs catpurex). If you do, I'd be happy if you explained ("avoids the shell?")