Thread CGI::Application: run_modes
(28 answers)
Opened by esskar at 2005-01-22 03:40
ich finde CGI::Application auch nicht so toll... ich baue mir meistens selbst einen groesseren config-hash, der alles steuert, und den ich dann mit dem html-parameter action anspreche, z.B.
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 package XYZ::Config; use warnings; use strict; use vars qw(%Config); %Config = ( start => { action => \&XYZ::Action::Start, template => 'start.tmpl', }, list => { action => \&XYZ::Action::List, template => 'list.tmpl', }, # ... ); und dann im hauptprogramm z.B. Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #! /usr/bin/perl use warnings; use strict; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBroser); my $cgi = CGI->new(); my $action = $cgi->param('action') || 'start'; if (exists $XYZ::Config::Config{$action} and ref($XYZ::Config::Config{$action}->{action}) ) { $XYZ::Config::Config{$action}->{action}->($cgi, $action, ...); } # if else { # fallback $XYZ::Config::Config{'start'}->{action}->($cgi, 'start', ...); } # else oder so aehnlich sowas in der art habe ich auch fuer das pboard verwendet\n\n <!--EDIT|Strat|1106384060--> perl -le "s::*erlco'unaty.'.dk':e,y;*kn:ai;penmic;;print"
http://www.fabiani.net/ |