in reply to main and external script

If you are creating a module to include configuration information, you might find the following useful. Firstly, we create the module that holds the configuration information, making sure the proper things are exported. Source:

package Testing; use strict; use Exporter; our @ISA = qw(Exporter); our (%EXPORT_TAGS); $EXPORT_TAGS{'config'} = [qw($verbose $debug)]; Exporter::export_ok_tags('config'); our ($verbose, $debug) = (1,1); 1;
And the main script that exploits the configuration information:

use strict; use warnings; use Testing qw(:config); print "I am ", $verbose ? "" : "not ", "verbose\n"; print "I should ", $debug ? "" : "not ", "debug\n";
When the code directly above is run, it produces, as expected:
I am verbose I should debug
For instance, if we changed this line ( our ($verbose, $debug) = (1,1); ) in the configuration module, to ( our ($verbose, $debug) = (undef,undef); ) we would get:
I am not verbose I should not debug

Replies are listed 'Best First'.
Re^2: main and external script
by gu (Beadle) on Dec 02, 2005 at 19:19 UTC
    Or you can use the great Damian Conways' Config::Std. Really good one.

    Gu