Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

crashtest's scratchpad

by crashtest (Curate)
on Feb 10, 2005 at 21:36 UTC ( #429922=scratchpad: print w/ replies, xml ) Need Help??

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;
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-09-20 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (159 votes), past polls