Perforce Public Knowledge Base - Script Debugging Tips: Perl
Reset Search
 

 

Article

Script Debugging Tips: Perl

« Go Back

Information

 
Problem

This article provides some suggestions for debugging Perl scripts used with Perforce.


Solution

Beyond the general trigger debugging suggestions given in Debugging Triggers, here are a few Perl-specific methods to make debugging Perl scripts easier. These very general methods are applicable whether you are using Perl to script triggers, or for other scripting applications such as daemons or command-line tools and scripts:

use strict;

Including this pragma at the head of all your scripts will enforce 'strict' use of subroutines, references and variable names. The practical use of this pragma is that it turns many run-time errors, which might be difficult to correctly detect and diagnose, into compile-time errors, making them easier to detect and correct.

For more information on this pragma, see the "strict" page at perldoc.org

use Data::Dumper;

Even if your script is syntactically correct, you might not get the results you expect, particularly if you are not sure what type of data a command returns. The Data::Dumper module will take a reference to a data structure (an array, hash or more complex data type) and print them out in Perl syntax, following internal references.

The Data::Dumper module is part of the Windows ActiveState distribution, or is available from CPAN Data-Dumper page.

Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255