Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Workflow to debug for a Perl programmer

Tags:

debugging

perl

I am new to Perl and I have the following problem.
I have a log output and I have found where this log output comes from. I mean the subroutine in some module that prints it.

Now e.g. in Java via Eclipse I would use e.g. Call hierarchy and other utilities to see how/when/who calls the method and figure out how to reproduce what I need and debug.

How can I do this in Perl? Via e.g. grep? If I grep e.g. for the module name I get hundrends of lines ranging from use A require A C::B::A B::A C::B::A::some_routine C::B::A::some_other_routine etc.
On top of this I am worried that perhaps the routine I am interested in is not called directly but some script e.g. runs the module that is of interest to me via some obscure (to me due to my ignorance in Perl) manner.

So how would I go debug something in Perl in the most efficient way? What do you Perl gurus suggest for me to do and become more efficient?

like image 229
Cratylus Avatar asked Aug 06 '26 17:08

Cratylus


1 Answers

Run the program under the Perl debugger:

perl -d scriptname arguments...

Set a breakpoint in the function you care about, and when the program stops at the breakpoint use the T debugger command to display a stack trace, which will show where the function was called from.

From your comments, I'm not sure this actually addresses what you're looking for. Maybe what you want is a cross-reference of the Perl application? See the FAQ How do I cross-reference my Perl programs?

like image 106
Barmar Avatar answered Aug 08 '26 09:08

Barmar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!