perl -c your_script.pl #### package jmdebug; # Debugging module # # # PURPOSE: to provide debugging information concerning methods # # CALLING FORMAT: # jmdebug::output("Description text",$scalarvariable_or_complex_reference); # Put the above line with modification in e.g. any metod calls you want to keep tabs on # In order to include several variables, do something like this: # jmdebug::output("Description text",\[$var1,$var2,\@array1]); # # BEHAVIOUR:checks to see if global var $debug is true, tries to gather information in a subroutine context # which is done with the caller(1) syntax. If that does not work does a plain caller(0) function call # Tries to pretty-print results use Data::Dumper; # used to display data structures sub output { if ($main::debug){ my ($pack, $filename, $line, $sub, $arg, $context, $dummy, $subname); ($pack, $filename, $line, $sub, $arg, $context) = caller(1) or ($pack, $filename, $line, $dummy, $arg, $context) = caller(0); $text = shift @_; my $datastructure = shift @_; $datastructure = Dumper($datastructure); $datastructure =~ s§^\$VAR1 \= §§; $subname = $sub; $subname =~ s§^.*\:\:§§; my ($pre, $post); if ($main::debug_html) { $pre = "
";
		$post = "
"; } print (qq§ $pre _____ / \\_________________________________________________ | | $subname : | ** $text ** | package: $pack | line: $line | in subroutine: $sub variable contains: $datastructure | |__________________________________________________________ $post§);} } 1;