in reply to Flow control / case structure

For one of my applications, I have all forms return an action (add, edit, delete, etc) and a type (Press Release, Press Cuttings, etc.). Then, I control the page and the function as follows:

# $action $type my %page_control = ( add => { PressRelease => { page => 'pm-mai +n-pr-add.tmpl', function => \&add_p +ress_release }, PressCutting => { page => 'pm-mai +n-pc-add.tmpl', function => \&add_p +ress_cutting } }, edit => { PressRelease => { page => 'pm-mai +n-pr-edit-del.tmpl', function => \&edit_ +press_release }, PressCutting => { page => 'pm-mai +n-pc-view.tmpl', function => \&view_ +press_cuttings } }, delete => { PressRelease => { page => 'pm-mai +n-pr-edit-del.tmpl', function => \&delet +e_press_release }, PressCutting => { page => '', function => '' } }, display=> { tabs => { page => 'pm-tab +s.tmpl', function => '' }, menu => { page => 'pm-men +u.tmpl', function => '' } }, default =>{ page => 'pm-main.tmpl', function => \&show_main_console } ); my $page = $page_control{ $action }{ $type }{ page }; my $function = $page_control{ $action }{ $type }{ function }; $page ||= $page_control{ default }{ page };

With that one data structure, it's relatively easy to track what's going on. However, I do want to look a bit more closely at CGI::Application as I lately hear its name getting bandied about quite a bit.

Cheers,
Ovid

Vote for paco!

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.