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.