in reply to How to Optionally enable threads in Perl 5.10.0

I don't know what they're talking about.
$ /usr/bin/perl -v This is perl, v5.10.0 built for i486-linux-gnu-thread-multi ... $ perl -e'eval "use threads; async { print qq{ok\n} }->join;"' ok

Maybe it's referring to symbol import? That passage is not present in newer version of Perl.

Mind you, it doesn't really make much sense to load threads conditionally. It seems to me it would make more sense to choose which module to use conditionally, one that uses uses threads, one that doesn't.

my $engine; if ($use_threads) { require Engine::Threaded; $engine = Engine::Threaded->new(); } else { require Engine::Fallback; $engine = Engine::Fallback->new(); }

Replies are listed 'Best First'.
Re^2: How to Optionally enable threads in Perl 5.10.0
by DrWhy (Chaplain) on Aug 09, 2010 at 18:27 UTC
    Yeah, I did the same thing just now:
    C:\Documents and Settings\Mine>c:\Perl5.10\bin\perl.exe -e "eval 'use +threads'; print \"$@\"; $t1 = threads->create(sub {print '1'}); $t2 = + threads->create(sub{print '2'}); $t1->join; $t2->join();" 12 C:\Documents and Settings\Mine>
    Requiring in diff't modules in the case at hand doesn't make much since. I'm only doing thread work in the main script, so the '*threaded' module would just contain the 'use threads' statement and the '*notthreaded' module would be empty (or just wouldn't exist).

    --DrWhy

    "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."