in reply to Perl thread issue

hmm

Warning, threads::shared has already been loaded. To enable shared variables, 'use threads' must be called before threads::shared or any module that uses it.
so
use threads; use threads::shared; use Thread::Queue;
ah
Running Thread1 : Thread::Queue=HASH(0xb7d8c4) sending command... sending command... running thread2 : Thread::Queue=HASH(0xbef644) Running Command : ls -la Result of ls -la : 'ls' is not recognized as an internal or external c +ommand, operable program or batch file. Running Command : pwd Result of pwd : 'pwd' is not recognized as an internal or external com +mand, operable program or batch file. Done

Replies are listed 'Best First'.
Re^2: Perl thread issue
by gurjit (Initiate) on Dec 29, 2016 at 00:10 UTC
    thanks man. I just loaded threads first and it solved. weird as load order shouldn't matter unless all those perl modules are loaded

      Hi gurjit,

      load order shouldn't matter

      That's true in many cases, but with certain modules, load order can matter. Note that use is equivalent to BEGIN { require Module; Module->import( LIST ); }, and the module's import method can be arbitrary Perl code, and require will essentially eval the file once, also allowing for arbitrary code to be executed. For many modules, they just contain sub definitions and don't execute any code that affects other things in your program, and their import is just Exporter's import and all it does is export certain names, or OO modules may not define an import at all. But a few modules out there can do some pretty complex things upon being used, and in that case, order of loading can make a difference.

      Regards,
      -- Hauke D

      Update: Previously, in the above I just talked about the effects of the import method; I've now updated the text to talk about the eval of the code as well.