Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

CGI::Carp in Apache::Registry

by bbfan (Novice)
on Jan 24, 2012 at 21:32 UTC ( #949773=perlquestion: print w/replies, xml ) Need Help??
bbfan has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

Yet again I seek the wisdom of the sages. Per the subject line, have been successfully using:

CGI::Carp qw(script_1.cgi); CGI::Carp qw(script_2.cgi); CGI::Carp qw(script_3.cgi);

in script1, script2 and script3 to log information. All was working well until the introduction of home-brewed precompilation of the scripts, which seemed to work well until I noticed that all the logging referred to just one of the scripts (for example, "script_2.cgi").

In a nutshell, the precompilation is great, but accurate logging is even better. Anyone have an idea how to resolve this problem so I can have both? Would prefer to stick with the home brewed, or a fixed version of it.

The home brewed precompile (added to is:

{ use File::Find; use ModPerl::RegistryLoader (); my $rl = ModPerl::RegistryLoader->new ( package => 'ModPerl::Registry', debug => '8', NameWithVirtualHost => '0', ); my $directory = "/var/www/html/"; my $uri = ""; opendir THISDIR, $directory or die $!; foreach ( @files = grep !/^\./, readdir THISDIR ) { $rl->handler( "/cgi-bin/$_" , "/var/www/html/$_", "" ); } }

As always, many thanks for your consideration.

Replies are listed 'Best First'.
Re: CGI::Carp in Apache::Registry
by Anonymous Monk on Jan 24, 2012 at 22:35 UTC

    You can't, it is not designed for that

    sub set_progname { $CGI::Carp::PROGNAME = shift; return $CGI::Carp::PROGNAME; }

    You can probably use

    BEGIN { set_progname( 'script_1.cgi' ); } END { set_progname( undef ); } Main( @ARGV );
      Hey, thanks for the suggestion. Sounded good, so gave it a try - had the same result as before. Went to see "when" an END block would get executed in Apache::Registry, and it's just what you might suspect - when the script or interpreter exits - which is why am seeing the same result.

        What is wrong with the default, caller...?

        In that case, copy/paste and fix it to your liking :) say it sets/checks  ${(caller)[0].'::PROGNAME'} instead, which ought to work under registry

      In thinking about this, am confused why it "seems to" work fine when not using the precompilation. If it is not designed for that, then how come it works? Am still fuzzy on much of the language. Thanks!

        In thinking about this, am confused why it "seems to" work fine when not using the precompilation.

        What do you mean by that? do you mean when it is run through mod_cgi?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://949773]
Approved by Eliya
[Corion]: Hurr - those people from that shady VPN / proxy backdoor site are persistent - today is the third time they've mailed me about backdooring my software with their "SDK".
[Corion]: I guess I should blacklist them on my mailserver directly.

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2018-05-21 14:03 GMT
Find Nodes?
    Voting Booth?