Introduction
This section is provided to give the ClearQuest administrator tips on debugging perl hooks.
Debugging Perl Hooks
Q: How can I debug my perl hooks?
A: Use dbwin32
To use dbwin32 to interactively debug your perl hook code while it is running in ClearQuest you need to do two things.
1. Start dbwin32.exe using Start>Run. Type dbwin32 into the run command line. A dialog opens where the output from your debug code will display as ClearQuest steps through your code.
2. Place this string "$session->$OutputDebugString("Place a message here describing where you are in your code and any $variableNames you may need $valuesFor \n");" wherever you think you need it.
 | Tip:
Placing your OutputDebugString inside your if statement will help you identify which statement gets executed at runtime.
if ($var1 == "X"){
Do something here
$session->OutputDebugString("Inside the IF where variable \$var is value $var");
}
else{
Do something else here
$session->OutputDebugString("Inside the ELSE where variable \$var is value $var - Not X ");
}
The message: Inside the IF where variable $var is value X OR Inside the ELSE where variable $var is value Y - Not X
will display in the dbwin32 window at runtime depending on which branch of the if statement was executed. |
3. Use the Test Work option on the File menu in ClearQuest Designer to test your schema.
Q: Are there any other tools I can use to debug perl hooks?
A: Use a third party integrated development environment (ide)
If you have access to the eclipse plugin for Perl from EPIC http://e-p-i-c.sourceforge.net
you can copy your hook code into the ide to debug. This is helpful for large hooks and is useful for identifying syntax errors.
Use strict; and Use warnings; are good practices for coding in perl. Use them when you can.
Another good editor/ide is available from Active State Corporation. Komodo IDE (licensed software) and Komodo Edit (free) can be found on http://www.activestate.com
.
Other editors for perl with built in syntax checkers can also be found on the internet.
 | Note:
Generally you cannot run your hook code to check and debug logic errors but sometimes it's helpful to copy your code into an ide so that you can identify any errors due to typos, misnamed variables and other common coding errors. |
See Also
http://e-p-i-c.sourceforge.net
http://www.activestate.com