perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Faust" <cfa...@doyougot.com>
Subject Re: Coding Style Question - Using exit
Date Tue, 19 Aug 2003 12:14:18 GMT
Thanks for the reply Thomas,

> Why not let determine_proper_action() return undef (or OK, or whatever) if
> you do not want to redirect? And in your handler do:
>
>   my $rv=determine_proper_action();
>   if ($rv) {  # or ($rv == Apache::Constants::OK)
>      # redirect
>   } else
>     # done
>   }
>
> One problem I can see is if you're exiting somewhere deep in a nested sub
> and you cannot propagate the return value back to the handler (easily).
>
>

That seems to be working well, I've changed that part of the handler to:

******************
 ($request_type,$back_url) = determine_proper_action();

 # Properly Exit the Handler from all subs within Determine Proper Action
 if ($request_type eq 'Apache::REDIRECT') {
  $r->headers_out->set(Location => $back_url);
        return Apache::REDIRECT;
 } else {
  return Apache::OK;
 }
*****************
Then in every sub within determine_proper_action I'm returning either
"Apache::OK" or "Apache::REDIRECT".

Still got a lot of testing to do, but so far I've been able to get rid of
all "exit"s from my script!

Thanks
-Chris




-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Mime
View raw message