Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^3: How to dynamically invoke one of several similarly named modules

by AnomalousMonk (Archbishop)
on Aug 22, 2022 at 19:41 UTC ( [id://11146300]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to dynamically invoke one of several similarly named modules
in thread How to dynamically invoke one of several similarly named modules

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:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11146300]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-26 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found