in reply to Using Perl Threads with Expect.pm

Just one question.
Now, I need to run the stuff in threadC only when the statements in threadB finish.
Then why are you running this in separate threads? Use a single thread for both tasks, and do them as a single normal, sequential, script.

Replies are listed 'Best First'.
Re^2: Using Perl Threads with Expect.pm
by vishi (Beadle) on Feb 17, 2011 at 13:32 UTC
    I am using threads to run B and C because threadA is also running. I believe that threadA would block the main thread until I do a join on it. Is my understanding wrong?
      According to : http://search.cpan.org/~rgiersig/Expect-1.21/Expect.pod#Is_it_possible_to_use_threads_with_Expect?

      Is it possible to use threads with Expect? Basically yes, with one restriction: you must spawn() your programs in the main thread and then pass the Expect objects to the handling threads.

      If I don't do this, or call create an Expect object in the main thread, the remote session is 'blocked', unless I pass the expect object to the thread subroutine...
      You misunderstand me. What I tried to say was not "Why threads?" but "Why 2 child threads, B and C?", thus: why are B and C 2 different threads instead of just one?

        Oh that! Well, ThreadB is doing stuff on a different server than ThreadC... so I need 2 threads to work across 2 machines.