In October of 2000, I posted a rough hack of a CGI variable debugging module that I had written. At the time, it had some issues which limited its functionality. Despite that, I thought it was useful enough that others might be interested. After a post here and some discussion on UseNet, I decided it was not ready for prime time. In particular, brian d foy pointed out that its functionality was easy to duplicate with print statements and a little extra code(though my interface was much cleaner and easier to control). He did mention, though, that it might be useful if I had a logging feature.

Here it is, over half a year later, and I've finally found the time to work on it again. I've added several new features. The two that are most useful are as follows:

What follows is a sample program and the output...

use strict; use warnings; use CGI::DebugVars; my $q = CGI->new(); my $write = CGI::DebugVars->new( -file => 'debug_test.html', -trace => 1 ); my $test = &sub_one; &sub_two; my $foo = 'foo test'; my @bar = qw/ Bilbo Frodo Ovid/; my $x = 1; $write->table( -header => 1, -active => 1, -condition => "$x > 0", FOO => $foo, TEST => $test, BAR => \@bar ); my $sub_three = &sub_three; $test = &sub_one; $x++; $write->table( -header => 1, -active => 1, -condition => "$x > 0", X => $x, FOO => $foo, TEST => $test ); $write->finish; sub sub_one { "\&sub_one works "}; sub sub_two { "Someone order a sub?" }; sub sub_three { "This is the third sub" };

The above code should produce the following:

Trace  
&sub_one
&sub_two
Caller, Package   main
Caller, Filename   C:\debug_test.pl
Caller, Line   15
BAR  
[
  'Bilbo',
  'Frodo',
  'Ovid'
]
FOO   'foo test'
TEST   '&sub_one works '
Trace  
&sub_three
&sub_one
Caller, Package   main
Caller, Filename   C:\debug_test.pl
Caller, Line   26
FOO   'foo test'
TEST   '&sub_one works '
X   2

For those who like POD, you can find it at this link or create it yourself from the module.

Unfortunately, I just discovered that my DESTROY method no longer appears to be called, so I need to call $debug->finish explicitly (and put it more cleanup code in the finishing routine). If anyone can tell me why, that would be great.

I don't think that it's necessarily ready for CPAN, but it's a lot farther along than it was.

Summary of above comments: please give feedback!

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to Debugging CGI Variables Revisited by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.