in reply to How to Optionally enable threads in Perl 5.10.0

Sure
use MyJunk;
package MyJunk; if( $] > 5.008008 ){ require MyJunk::threads; } else { require MyJunk::nothreads; }

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:18 UTC
    That's interesting, but if it's unsafe to 'require threads' directly, seems that this approach is just doing the same thing indirectly and would suffer the same kind of problem. If the problem is just that you must be sure that threads is there at compile time maybe something like this would work:
    BEGIN { if ($] > 5.008008) { require threads; } }

    --DrWhy

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