Scott, Try this instead
sub cgiapp_prerun { $self->prerun_mode('redirect_to_perl') if( $req_not_met ); } sub redirect_to_perl { my $self = shift; $self->header_props (-uri => 'http://www.perl.com/'); $self->header_type ('redirect'); return 1; } The prerun_mode() method is used to change the run-mode that will be called upon exiting cgiapp_prerun(). Unless you change the run mode specifically to something else, CGI::App will still try to execute the runmode it thinks it's supposed to run. > Hi Folks: > > I know I'm being dense, but I can't wrap my head around this.... > > I have a situation where I need to redirect to another location (outside of > this cgiapp) if certain security requirements aren't met. So, I do this in > cgiapp_prerun: > > if ($req_not_met) { > $self->header_props (-uri => 'http://www.perl.com/'); > $self->header_type ('redirect'); > return $self->emptiness; > } > > and sub emptiness is just: > > sub emptiness { > return 1; > } > > This prints the correct HTTP header: > > Status: 302 Moved > Location: http://www.perl.com/ > > BUT, it also prints the output of my runmode which should be run if the > requirements _are_ met. > > I've experimented with postrun, teardown, etc., but can find no joy. > > If anyone has any helpful thoughts or gentle dope-slaps, I'd be glad for > them. > > TIA, > s. > > -- > Scott Hepler > System Administration and Security > Web Development > (802) 457-3796 > > --------------------------------------------------------------------- > Web Archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]