Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

(Ovid) Re: Flow control / case structure

by Ovid (Cardinal)
on Sep 08, 2001 at 02:46 UTC ( [id://111060]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-24 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found