Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I'm fairly new to Perl and particularly new to it for CGI
I want to get the basic right for seeing debug output to my browser
so far I have

#!/usr/bin/perl -wT BEGIN { $|=1; print "Content-type: text/html\n\n"; use CGI::Carp('fatalsToBrowser'); } use strict; use CGI; $var = 'hello world'; print $var;

This doesn't give me the compilation errors that it should(?).
Is there anything else I can add to make this more verbose.
I want to be able to see all the compilation warnings that use strict offers me

thanks in advance of any help

Cyril

jdporter - edited - added proper html and code tags

20040324 Edit by castaway: Changed title from 'cgo::carp compilation errors'

Replies are listed 'Best First'.
Re: cgi::carp compilation errors (bug)
by tye (Sage) on Mar 24, 2004 at 06:09 UTC

    There were several versions of CGI::Carp that failed to catch compile-time errors. Upgrade or downgrade.

    - tye        

Re: CGI::Carp compilation errors
by neniro (Priest) on Mar 23, 2004 at 21:22 UTC
      I still get
      Global symbol "$var" requires explicit package name
      at /usr/local/apache/htdocs/cgi-bin/debug.cgi line 13.
      Global symbol "$var" requires explicit package name
      at /usr/local/apache/htdocs/cgi-bin/debug.cgi line 14.
      Execution of /usr/local/apache/htdocs/cgi-bin/debug.cgi
      aborted due to compilation errors.

      appearing in my apache error log rather than my browser

      my question is more out of curiosity than necessity.

Re: CGI::Carp compilation errors
by eXile (Priest) on Mar 24, 2004 at 01:48 UTC
    If I run your script from the commandline I get:
    Content-type: text/html <h1>Software error:</h1> <pre>Global symbol &quot;$var&quot; requires explicit package name at +/home/emile/tmp/aap.pl line 13. Global symbol &quot;$var&quot; requires explicit package name at /home +/emile/tmp/aap.pl line 14. Execution of /home/emile/tmp/aap.pl aborted due to compilation errors. </pre> <p> For help, please send mail to this site's webmaster, giving this error + message and the time and date of the error. </p>
    Which makes me pretty sure the fatals/warnings are processed as if they'd go to a browser. My guess is that you are using some form of cached web-environment (mod_perl-ish maybe?). What happens if you restart your webserver?
Re: CGI::Carp compilation errors
by ambrus (Abbot) on Mar 24, 2004 at 15:48 UTC

    As a quick and dirty solution (I actually have this in a cgi):

    use warnings; use strict; sub pr { print @_, "\n" }; sub pp { print "<P>", @_, "\n" }; sub pb { print "<P><B>", @_, "</B> \n" }; sub pq { my $x= join "", @_; $x=~s!([^a-zA-Z0-9.,:;_\!?\-+*/="'`(){}\[\]\\\\@#\$^~ \n])! sprintf("&#x%x;",ord$1) !ge; $x=~s!^ | (?= |$)!&nbsp;!gm; $x=~s!\n!<BR>!g; print $x, "\n"; } BEGIN { print qq{Content-Type: text/html \nCache-Control: no-cache \n\n <HTML> +}; $SIG{__DIE__}= sub { pb "die "; pq $_[0]; pr "</HTML>"; die $_[0]; }; $SIG{__WARN__}= sub { pp "warn "; pq $_[0]; pr "</P>"; }; };