ydnar wrote:
The eval() is unecessary. The named sub can be used:
&$func();
yes but not with use strict ...
mod_perl remaps exit() to ModPerl::Util::exit(). Are you sure the right modules are being loaded?
You don't need to load anything. Indeed under mp2:
*CORE::GLOBAL::exit = \&ModPerl::Util::exit;
And you don't need to load anything for this to work.
in mp2 exit is implemented via a special die() call, therefore if you call it inside eval { } block (and eval "STRING" behaves identically) an exception is being thrown, but caught by eval.
for me, both solution don't work :-(( maybe me installation is wrong ... the output is always the sum of &first &second
So in your case you either need to rethrow it:
use ModPerl::Util qw(exit); my $func = 'first'; eval "\&$func"; exit if $@; &second();
#!/usr/bin/perl use strict; use CGI qw(:standard);
# &first(); my $func = 'first'; eval "\&$func"; # northing is print ! # print "$@<br>"; exit if $@;
&second();
sub first { print header(); print "In first<br>"; exit(0); }
sub second { print "In second<br>"; print "I dont want to see this part !"; }
1;
=pod
# in standad cgi, the output is
In first
# in mod_perl, the output is
In first In second I dont want to see this part !
# nothing in erreur log
=cut
or use the CORE::exit:
sub first { ... CORE::exit(0); }
#!/usr/bin/perl
use strict; use CGI qw(:standard);
use ModPerl::Util qw(exit); my $func = 'first'; eval "\&$func"; # nothing is print ! # print "$@<br>"; exit if $@; &second();
sub first { print header(); print "In first<br>"; exit(0); }
sub second { print "In second<br>"; print "I dont want to see this part !"; }
1; =pod
# in standad cgi, don't work (of course of use ModPerl::Util)
# in mod_perl, the output is
In first In second I dont want to see this part !
# nothing in erreur log
=cut
the problem with the latter is that it kills the process (or the interpreter if under threads), but it'll behave like mod_cgi and work the same under mod_cgi.
So choose your poison.
Also you can write your own exit function which will do what you want if neither of the two is satisfactory.
Arnaud
-- 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