Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by onemojofilter (Novice)
on Aug 22, 2022 at 18:21 UTC ( [id://11146297]=note: print w/replies, xml ) Need Help??


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

Yes, that does sound more reasonable. I was stuck on the examples I was shown but I suppose I needed a second pair of eyes.

Much appreciated!

Replies are listed 'Best First'.
Re^3: How to dynamically invoke one of several similarly named modules
by AnomalousMonk (Archbishop) on Aug 22, 2022 at 19:41 UTC

    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://11146297]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2024-03-28 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found