Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2016-12-10 20:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (165 votes). Check out past polls.