So I run a file in the perl debugger using perl -d file.pl. But then the file.pl is supposed to take arguments also. How do I supply arguments to the file.pl One more question: file.pl has this line in it:
system("./file2.pl");
Is there a way to set a breakpoint in file2.pl if it is running as system
? I have spent 7 days on perl debugger and I am not able to set a breakpoint at file2.pl Please help
EDIT: Got an awesome response from DVK to add DB::single=1. I tested that on some files and it worked. But I have more than a 100 files and if I do this manually, it will take me a lot of time. I use .perldb and use afterinit to typeahead all commands. I have put in place an algorithm which finds the line number of each file where the breakpoint needs to go. I just can't randomly (automatically using an executable) open all those files and add DB::single=1 to where I like. The whole system can crash then. I want to set breakpoint as it more secure
Yes, you can.
Add the following code to the line where you want to break in file2.pl
:
$DB::single = 1;
To control the debugging automatically from that point, you need to manipulate @DB::typeahead
array. From perldoc:
You can mock TTY input to debugger by adding arbitrary commands to @DB::typeahead. For example, your .perldb file might contain:
sub afterinit { push @DB::typeahead, "b 4", "b 6"; }
This code can be either in a BEGIN {}
block, or a special .perldb
config file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With