Geoffrey Young wrote:
  if (eval { require 'AxKit' }) {
     Apache::TestRunPerl->new->run(@ARGV, '-defines', 'AXKIT');
  }
  else {
     Apache::TestRunPerl->new->run(@ARGV);
  }

HTH

--Geoff

OK, I found something strange that I so don't understand at all. Can someone clue me in?

I tweaked the extra.conf.in to use IfDefine. I decided to tweak my Makefile.PL to push -defines into @ARGV. This worked great for Template:

use ExtUtils::MakeMaker;
use 5.006;
use strict;
use warnings FATAL => 'all';

eval 'use Apache::Test 1.16';
if (!$@) {
    require Apache::TestMM;
    Apache::TestMM->import(qw(test clean));

    eval 'use Template';
    if (!$@) {
        push @ARGV, '-defines', 'TT2';
    };

    Apache::TestMM::filter_args();
    Apache::TestMM::generate_script('t/TEST');
    Apache::TestMM::generate_script('t/SMOKE');
};

t/TEST contains the expected -defines TT2.

However, if I try to eval 'use AxKit' ANYWHERE in Makefile.PL like so:

use ExtUtils::MakeMaker;
use 5.006;
use strict;
use warnings FATAL => 'all';

eval 'use Apache::Test 1.16';
if (!$@) {
    require Apache::TestMM;
    Apache::TestMM->import(qw(test clean));

    eval 'use Template';
    if (!$@) {
        push @ARGV, '-defines', 'TT2';
    };

    eval 'use AxKit';

    Apache::TestMM::filter_args();
    Apache::TestMM::generate_script('t/TEST');
    Apache::TestMM::generate_script('t/SMOKE');
};

perl Makefile.PL chokes with:

C:\Development\CPAN\Handel>perl Makefile.PL
[   info] generating script t/TEST
"C:\Development\CPAN\Handel" is not exported by the lib module
Can't continue after import errors at 
C:/Development/Perl/584/site/lib/Apache/TestConfig.pm line 223

This is under Apache::Test 1.18

What confuses me is this. If I change eval 'use AxKit' to your example of eval {require 'AxKit'}; ... all is well.


use ExtUtils::MakeMaker; use 5.006; use strict; use warnings FATAL => 'all';

eval 'use Apache::Test 1.16';
if (!$@) {
    require Apache::TestMM;
    Apache::TestMM->import(qw(test clean));

    eval 'use Template';
    if (!$@) {
        push @ARGV, '-defines', 'TT2';
    };

    eval {require 'AxKit'};

    Apache::TestMM::filter_args();
    Apache::TestMM::generate_script('t/TEST');
    Apache::TestMM::generate_script('t/SMOKE');
};

I know there's some deep magic going on there, but I'm unclear how it's effecting A::T...

Based on your past experience, what is the safest thing to do?

eval 'require Foo;'
eval 'use Foo;'
eval {require 'Foo'};


Thanks, -=Chris

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



Reply via email to