How to set breakpoint on a particular file in Perl program?

前端 未结 2 905
南旧
南旧 2021-02-02 10:23

My Perl program looks like:

foo/
foo/bar/
for/bar/test.pm
foo.pm
foo/bar.pm
test.pl

and use perl test.pl to start the program. I

2条回答
  •  梦谈多话
    2021-02-02 10:51

    To debug a perl script, use the -d switch to invoke the debugger.

    perl -d test.pl
    

    Within the debugger you can use b to set a breakpoint in the current file. Sometimes it is a hassle to set a breakpoint in a file that hasn't been loaded yet or that was loaded a long time ago, so you can also put the line

    $DB::single = 1;
    

    anywhere in any perl program, and the debugger will break immediately after it executes that line. This is also a good way (the only way?) to set a breakpoint in code that will be run at compile time.

提交回复
热议问题