Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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 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
Node Status?
node history
Node Type: perlquestion [id://949773]
Approved by Eliya
help
Chatterbox?
[choroba]: LanX I miss working in a bank sometimes...
[Corion]: Discipulus: Ooof. Especially yearly things are things I like to automate instead of trying to remember how I did things last year...
[Corion]: And the second rule that I've learned is, that there is no one-off job, so writing a program for it pays off almost immediately. The third rule is to give all my programs numbers and have them reproduce that number in the name of their output files. :)
[Discipulus]: the true part is that also specification change between years.. but well our job is cheap but dont abuse of us.. ;=)
[LanX]: Choroba: do you miss chaos with ties? apply at the US government.. ;)
[ambrus]: Corion: those are good rules.
[ambrus]: Discipulus: oh sure. the input data has different filenames every time I get them.
[ambrus]: the directory structure may be 1, 2, or 3 deep, it may have spaces in the filename or not, it has dates in various format, different keywords for the same meanings, and the dates and other keywords are assembled in various ways.

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (14)
As of 2017-03-29 12:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (350 votes). Check out past polls.