package Something::Config;
use strict;
use warnings;
#use diagnostics;
use Carp;
use Readonly;
use Exporter qw( import );
Readonly::Array my @KNOWN_ENVIRONMENTS => (
{ test => \&is_crashtest_workstation, action => \&setup_crashtest_
+workstation },
# (more to be added)
);
# this works
{
no warnings 'redefine';
eval "sub import { SUPER->import(@_); setup_env(@_) }";
}
# ... but i was trying to do this:
#sub import {
# SUPER->import(@_);
# setup_env(@_);
#}
sub setup_env {
for my $env (@KNOWN_ENVIRONMENTS) {
my $test = $env->{test};
my $action = $env->{action};
if ($test->()) {
$action->(@_);
return;
}
}
carp "Can't identify this environment; add to Something::Config as
+ needed!";
}
######################################################################
+##########
### WORKSTATION SETUP
sub is_crashtest_workstation {
return $^O eq "MSWin32"
&& $ENV{COMPUTERNAME} eq "ABCDEF123";
}
sub setup_crashtest_workstation {
if (! exists $ENV{ORACLE_HOME}) {
$ENV{ORACLE_HOME} = 'C:\yada\yada';
}
}
# more to be added...
1;
|