in reply to Testing subroutines from a script

If you're running your tests under Test::Harness, it'll set $ENV{HARNESS_ACTIVE} for you. You can then write:

sub main { # everything you'd normally execute here } main() unless ($ENV{HARNESS_ACTIVE});

Replies are listed 'Best First'.
Re: Re: Testing subroutines from a script
by mp (Deacon) on Aug 30, 2002 at 19:40 UTC
    Thank you. This works great. I added
    BEGIN { $ENV{HARNESS_ACTIVE} = 1 }
    to the test script so that it will work regardless of whether it is invoked under Test::Harness.