Alex Rivera | Logout

Can I insert break point into source perl program?

Asked 2011-01-14T13:20:00.240
17

I want the perl program launch debugger when some condition hit. Some other language has debug() statement supported by library, is there any similar statement in perl?

Edit
Report

1 Answer

6

Have you tried adding the -d switch to the shebang line at the top of your script? Something like

#!/usr/bin/perl -d
use strict;
use warnings;
$|=1;$\="\n";

print "Test";

It really depends exactly how it gets launched, but at least in simple cases this should start the debugger.

Edit: You can then set a breakpoint on a specific line with a certain condition using

> b [line] [condition]

and hit

> c

to continue with running the script - the debugger will stop at the specified line when the condition is met

answered 2011-01-14T15:00:17.400

Your Answer