in reply to Changing run mode in cgi::application

It's a little unclear exactly what you're doing, but I'm guessing it's something like this (code oversimplified but I hope it's clear):
sub myRunmodeA { my $self = shift; my $isOK = blah (foo, bar) ... } sub myRunmodeB { my $self = shift; fixBlahProblem(); ... } sub blah { return if param('problem') eq 'true'; }
What you want to do is, if myRunmodeA finds a problem, switch to myRunmodeB. There's nothing particularly magic about the run mode -- once your CGI::Application has been brought to life by the user, you are a class, so you can just call myRunmodeB, i.e. (using code from my example above):
sub myRunmodeA { my $self = shift; if( blah (foo, bar) ) { #usual code } else { return $self->myRunmodeB; } }

(You might want to set the runmode before hopping into myRunmodeB, just for good luck. You probably do that with $self->{rm} = 'myRunmodeB', but this depends on how you set things up in CGI::Application:setup).

Hope that helps!

Alan

Replies are listed 'Best First'.
Re: Re: Changing run mode in cgi::application
by BUU (Prior) on Mar 23, 2004 at 22:35 UTC
    While what you describe is possible, it seems ugly/annoying to have to add that logic to every single run mode that uses my utility method. It would be so much cleaner if I could just replace the currently running run_mode with a new one that handles the error, but I can't figure out how.