in mp 1.x land, <Perl> sections used to set $0 to the name of the configuration file it was in.
Following patches does just that for 2.x
Index: Changes
===================================================================
RCS file: /home/cvs/modperl-2.0/Changes,v
retrieving revision 1.250
diff -u -I$Id: -r1.250 Changes
--- Changes 13 Nov 2003 21:03:46 -0000 1.250
+++ Changes 14 Nov 2003 17:40:29 -0000
@@ -12,6 +12,9 @@
=item 1.99_12-dev
+<Perl> sections now proprely set $0 to the name of the configuration
+file they are in. [Philippe M. Chiasson]
+
<Perl> sections now proprely set filename and line number information,
making error messages report the correct location. [Philippe M. Chiasson]
Index: src/modules/perl/modperl_cmd.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.c,v
retrieving revision 1.50
diff -u -I$Id: -r1.50 modperl_cmd.c
--- src/modules/perl/modperl_cmd.c 13 Nov 2003 21:03:46 -0000 1.50
+++ src/modules/perl/modperl_cmd.c 14 Nov 2003 17:40:29 -0000
@@ -409,6 +409,8 @@
arg, NULL);
}
+ sv_setpv(get_sv("0", TRUE), parms->directive->filename);
+
eval_pv(arg, FALSE);
if (SvTRUE(ERRSV)) {
Index: t/conf/extra.last.conf.in
===================================================================
RCS file: /home/cvs/modperl-2.0/t/conf/extra.last.conf.in,v
retrieving revision 1.8
diff -u -I$Id: -r1.8 extra.last.conf.in
--- t/conf/extra.last.conf.in 13 Nov 2003 21:03:46 -0000 1.8
+++ t/conf/extra.last.conf.in 14 Nov 2003 17:40:29 -0000
@@ -24,6 +24,7 @@
<Perl >
$Apache::Server::SaveConfig = 1;
$TestDirective::perl::filename = __FILE__;
+$TestDirective::perl::dollar_zero = $0;
$TestDirective::perl::line = __LINE__;
</Perl>
Index: t/response/TestDirective/perldo.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestDirective/perldo.pm,v
retrieving revision 1.4
diff -u -I$Id: -r1.4 perldo.pm
--- t/response/TestDirective/perldo.pm 13 Nov 2003 21:03:47 -0000 1.4
+++ t/response/TestDirective/perldo.pm 14 Nov 2003 17:40:29 -0000
@@ -10,7 +10,7 @@
sub handler {
my $r = shift;
- plan $r, tests => 7;
+ plan $r, tests => 8;
ok t_cmp('yes', $TestDirective::perl::worked);
@@ -21,6 +21,8 @@
ok t_cmp('PerlSection',
$Apache::ReadConfig::Location{'/perl_sections_saved'}{'AuthName'});
ok t_cmp('yes', $TestDirective::perl::comments);
+
+ ok t_cmp(qr/extra.last.conf/, $TestDirective::perl::dollar_zero, '$0');
ok t_cmp(qr/extra.last.conf/, $TestDirective::perl::filename, '__FILE__');
--
--------------------------------------------------------------------------------
Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5 (122FF51B/C634E37B)
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5
Q: It is impossible to make anything foolproof because fools are so ingenious.
perl -e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'
signature.asc
Description: This is a digitally signed message part
