One thing I find myself constantly doing with my SOAP::Lite clients is commenting in and out the "+trace => 'debug'" from the "use SOAP::Lite" call so that I can turn on and off debugging information. This became so annoying to me that I decided to programitize it. Now I just turn debugging on and off with a command line flag.
The following code fragment shows how you can easily turn on and off SOAP::Lite debugging information from the command line. Obviating your need to go into the code everytime you want to toggle debugging:
use Getopt::Long;
my $result = GetOptions ("debug" => \$DEBUG);
if ($DEBUG) {
eval "use SOAP::Lite +trace => 'debug';";
} else {
eval "use SOAP::Lite;";
}
Note: The Getopt::Long package typically comes standard with Perl, but if for some reason your Perl doesn't have it, just download it from CPAN.
You can also use the following:
use SOAP::Lite;
use Getopt::Long;
my $result = GetOptions ("debug" => \$DEBUG); # No 'my' for $DEBUG? :-)
$DEBUG && SOAP::Lite->import(trace => debug);
Posted by: Randy Jay | April 30, 2003 at 09:43 AM