Thanks, Ben.
I went ahead and bit the bullet.
I wrote a function that takes, among other arguments, an entity type
and an action type, so now I just call one procedure. It did require a
translation table as you suggested (which I hard coded for now but
will probably put into a database), but that's a lot easier on the
eyes than a couple hundred lines of elsif statements.
As a bonus, I am able to abstract my SQL as well. In my code, I have
procedures to:
- add
- insert
- view all
- view one
- edit
- update
- delete
for a dozen different categories, Insurers, Employers, Attorneys,
Agents, etc. It started out pretty small, but man, scaling becomes an
issue when different people start adding their wants to the list!
Saying, 'Yes, I can do a little app to track the players,' turns into
a Sunday at the keyboard when the office gets a crack at it.
On Jul 5, 4:00*pm, Ben Morrow <b...@morrow.me.uk> wrote:
> That's a good suggestion. Another might be to use a hash table of
> subrefs, like
>
> * * my %dispatch = (
> * * * * AddAttorney => sub {
> * * * * * * print qq(<h4>Add Attorney</h4>);
> * * * * * * HTML::add_professional($oprid, $role, 'Attorney');
> * * * * * * HTML:
rint_button('setup.cgi','Return To Setup',
> * * * * * * * * $oprid, $role);
> * * * * },
> * * * * AddInsurer => sub { ... },
> * * );
>
> * * $dispatch{$action}();
>
> or even a class with a method for each action.
One of these days, I'm going to learn OO Perl. I've got two books on
my reading list, 'Object Oriented Perl' and 'Higher Order Perl', but
I've never been able timewise to do more than just browse through
them.
Thanks for your suggestion.
CC