Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

CGI::Carp in Apache::Registry

by bbfan (Novice)
on Jan 24, 2012 at 21:32 UTC ( [id://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 startup.pl) is:

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

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.

      http://perl.apache.org/docs/2.0/api/ModPerl/Registry.html#C_END__Blocks

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

        In that case, copy/paste Carp.pm 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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://949773]
Approved by Eliya
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-03-19 10:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found