The pseudo-code for the way I imagine implementing this is something like:
use DataBaseDriver; ... use constant CITIES => qw(lon par); use constant APPLICATIONS => qw(test prod); # build dispatch table for database handles my %db_handle; for my $city (CITIES) { for my $app (APPLICATIONS) { $db_handle{$city}{$app} = DataBaseDriver->new or die "'$city:$app' driver creation failed: ", DataBaseDriver->error_msg; } } ... # use database handle dispatch table my $msg = '...'; my $city = '...'; my $app = '...'; my $dbh = $db_handle{$city}{$app} or die "'$city:$app' driver access failed"; $dbh->store_to_database($msg); ...
Give a man a fish: <%-{-{-{-<
In reply to Re^3: How to dynamically invoke one of several similarly named modules
by AnomalousMonk
in thread How to dynamically invoke one of several similarly named modules
by onemojofilter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |