top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Skipping X Number of Iterations before Stopping on a Break Point in Perl?

+1 vote
300 views

I am running a script under perl -d and want to break execution at line 243 in this case. perl -d scriptname loads the script in to the debugger and b 243 sets the break point. c then Enter starts the program which runs until it reaches the desired line at which point it stops. All I want to do is get it to loop multiple times through this point and then stop.

This is similar to the behavior of gdb where you could tell it to stop after, say, 250 passes through the break point.

posted Feb 28, 2014 by Abhay Kulkarni

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

I know of several options for that:

  1. Use a package-scope count variable: e.g, do:

    b 243 ((++$::_LINE_243) == 250)
    
  2. source a file (see "source" on "perldoc perldebug") that will contain several "c" statements.
  3. Maybe try Devel::Trepan instead: https://metacpan.org/release/Devel-Trepan .
answer Feb 28, 2014 by anonymous
Similar Questions
0 votes

I am using constant mainly to enable printing of debugging messages (e.g. use constant DEBUGGING_L1 => 0;)

Normally, the value is '0' and when I need to see debug messages, I make this 1 and run the script. Is there a way to allocate value to constants at run time so that I can avoid editing the script again and again?

Also, is there a better way to handle debugging?

...