Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I would prefere to do something like the above, instead of a large if/else statement, that way, when I add a new vendor - I need only add the associated package to the Modules directory and be up and running - instead of modifying the if/else to include the new condition. Any ideas if this is even possible? Richard Luck Pif Magazinesub getVendorData { my ($code) = @_; my $returnedVal = 0; if($code =~ m/<%(\w+)%>/) { # need to do something special with this vendor my $module = $1; # $module is the package name # (it could be one of 7 different values) # where we'll add any custom stuff that needs to happen for a # particular vendor use Modules::$process; # for example my $vendor = $process->new(); # for example my $returnedVal = $vendor->getVendorData(); } return $returnedVal; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I dynamically declare a package name for
by hdp (Beadle) on Apr 27, 2001 at 08:44 UTC | |
|
Re: How do I dynamically declare a package name for
by gildir (Pilgrim) on Apr 27, 2001 at 13:36 UTC | |
by hdp (Beadle) on Apr 27, 2001 at 16:09 UTC | |
by gildir (Pilgrim) on Apr 27, 2001 at 21:14 UTC | |
|
Re: How do I dynamically declare a package name for
by Rhandom (Curate) on Apr 27, 2001 at 16:43 UTC | |
|
Re: How do I dynamically declare a package name for
by jepri (Parson) on Apr 27, 2001 at 08:33 UTC | |
|
Re: How do I dynamically declare a package name for
by busunsl (Vicar) on Apr 27, 2001 at 09:53 UTC | |
by hdp (Beadle) on Apr 27, 2001 at 16:22 UTC | |
|
Re: How do I dynamically declare a package name for
by Anonymous Monk on Apr 27, 2001 at 08:35 UTC |