perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [MP2] eval and exit(0) : problem
Date Mon, 03 May 2004 17:34:05 GMT
Arnaud Blancher wrote:
[...]
>> try:
>>
>>   {
>>     no strict 'refs';
>>     &$func();
>>   }
> 
> yes, it's work.
> i'don't realy like this solution, just because i always  try to use 'use 
> strict'
> to avoid problem with mod_perl !!!!

But in this case, it disables strict refs only for a very small scope! It 
doesn't affect anything else, so you perfectly fine.

> so, could you tell me if the final mp2, will have a solution for exit in 
> eval function ?
> in this case i'll wait and keep my complete 'use strict'
> in the other case .. may be i will change all my script, and lost a part 
> of 'strict'.

I have a working solution (haven't committed yet), but I'm not 100% sure yet 
that it's going to stay, I have received no feedback so far on this proposal [1].

At the moment looks like:

use ModPerl::Const -compile => 'EXIT';

eval {
      my $whatever = 1;
      exit();
};
exit if $@ && ref $@ && $@ == ModPerl::EXIT;

The same will work for eval $string.

What happens here is that exit calls die with an exception object, which you 
can observe outside the eval block (the numerical context of $@ will return 
ModPerl::EXIT value) and rethrow exit (or do return or else) to cleanly quit 
the handler w/o killing the process.

If you wish, you can get the current cvs, apply my patch [1] and try the 
thing. You can see t/response/TestModperl/exit.pm which exercises this 
functionality.

[1] http://marc.theaimsgroup.com/?l=apache-modperl-dev&m=108354831109582&w=2

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Mime
View raw message