in reply to Re: Include module at compile time with condition
in thread Include module at compile time with condition

Thats what im looking for
Thanks a lot
I made a slight change ( of course both are same ) for the coding style

use if ( MICRO_SEC ) , Time::HiRes => qw(time) ;

Replies are listed 'Best First'.
Re^3: Include module at compile time with condition
by Eliya (Vicar) on May 07, 2011 at 07:37 UTC

    Note that the fat comma doesn't work here under use strict (i.e., you'd still need to quote the module name):

    #!/usr/bin/perl use strict; use if ( 1 ) , Time::HiRes => qw(time) ;
    $ ./903506.pl Bareword "Time::HiRes" not allowed while "strict subs" in use at ./903 +506.pl line 3. Execution of ./903506.pl aborted due to compilation errors.
      Eliya wrote:
      Note that the fat comma doesn't work here under use strict (i.e., you'd still need to quote the module name):
      #!/usr/bin/perl use strict; use if ( 1 ) , Time::HiRes => qw(time) ; $ ./903506.pl Bareword "Time::HiRes" not allowed while "strict subs" in use at ./903 +506.pl line 3. Execution of ./903506.pl aborted due to compilation errors.
      That’s easily fixed. The fat‐comma isn’t the only way to please use strict, you know. Just use “package-quoting” on the module name: Time::HiRes::. Now that doesn’t even need fat‐comma any longer:
      % perl -Mstrict -e'printf "%s is %d chars long.\n",
                              English::, length(English::)'
      English is 7 chars long.
      
      See how that works? Perfectly use strict–complaisant, too. Nifty, eh? That means that this compiles and runs just fine:
      #!/usr/bin/perl use strict; use if ($^V gt v5.7.3), Time::HiRes::, qw(time);
      And so does this:
      #!/usr/bin/perl use strict; use if $^V >= v5.7.3 => Time::HiRes:: => time => ();

      Although some of that there just might maybe get you a tad talked about.   😻