in reply to CGI::Application same function code

I take a different approach. Since all CGI::Application runmodes are just object methods, I install the methods when the class is compiled. Then, I treat them as ordinary runmodes when I write my setup().
sub install_method { my $package = shift; foreach my $method (@_) { no strict 'refs'; *{$package . '::' . $method} = sub { # Do whatever you want here. You can reference $method and + any other # lexical variables, just like any closure. }; } } __PACKAGE__->install_method qw( start middle end );

Generally, I will put install_method() in my CGIApp baseclass. (You do have a CGIAPP baseclass, right?)

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^2: CGI::Application same function code
by boboson (Monk) on Feb 13, 2005 at 12:03 UTC
    I am actually just in the planning state, I've done some testcode just to be certain that I design this correctly from the beginning. I will use a baseclass but I havn't decided exactly how yet.

    Is there any chance that you could explain a little bit further how I could implement your suggestion?

      Re: Why CGI::Application? is a good start on the topic.

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

        great!