how to skip to a certain loop with debugging option perl -d

Discussion in 'Perl Misc' started by Hendrik Maryns, Jan 17, 2005.

  1. Hi,

    i've been reading perldebut and it already helped me solving that
    annoying warning that kept occurring, but not on the most efficient way:
    I had to skip through 61 executions of a loop before reaching it!

    So I was wondering: is there something like the c option that skips
    through /N/ iterations of a loop, before stopping at the breakpoint
    again (which is inside the loop, obviously). I didn't find anything
    like that described in perldebug, so this time I thought I'd dare asking
    (I started to read the guidelines indeed:p)

    Cheers, H.
     
    Hendrik Maryns, Jan 17, 2005
    #1
    1. Advertising

  2. Bob Walton schreef:

    > Hendrik Maryns wrote:
    >
    >> Hi,
    >>
    >> i've been reading perldebut and it already helped me solving that
    >> annoying warning that kept occurring, but not on the most efficient
    >> way: I had to skip through 61 executions of a loop before reaching it!
    >>
    >> So I was wondering: is there something like the c option that skips
    >> through /N/ iterations of a loop, before stopping at the breakpoint
    >> again (which is inside the loop, obviously). I didn't find anything
    >> like that described in perldebug, so this time I thought I'd dare
    >> asking (I started to read the guidelines indeed:p)
    >>
    >> Cheers, H.

    >
    >
    > Well, the "b" (break) debugger command has an optional third argument
    > which is a condition that must be true for the break to occur. So, for
    > example:
    >
    > for(0..50){
    > print "$_\n";
    > }
    >
    > can be broken on the iteration when $_ is 10 with:
    >
    > b 2 $_==10
    > c
    >
    > For example:
    >
    > D:\junk>type junk513.pl
    > for(0..50){
    > print "$_\n";
    > }
    >
    > D:\junk>perl -d junk513.pl
    >
    > Loading DB routines from perl5db.pl version 1.25
    > Editor support available.
    >
    > Enter h or `h h' for help, or `perldoc perldebug' for more help.
    >
    > main::(junk513.pl:1): for(0..50){
    > DB<1> b 2 $_==10
    > DB<2> c
    > 0
    > 1
    > 2
    > 3
    > 4
    > 5
    > 6
    > 7
    > 8
    > 9
    > main::(junk513.pl:2): print "$_\n";
    > DB<2> x $_
    > 0 10
    > DB<3> q
    >
    > D:\junk>
    >
    > Does that help?


    Yes, perfect, thanks (it might seem a strange question, but it is
    because the problem wasn't in the code, but in the input data. Of
    course I slightly changed the code to catch that...)
    H.
     
    Hendrik Maryns, Jan 18, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    661
  2. Jacob Rael

    skip item in list "for loop"

    Jacob Rael, Apr 14, 2006, in forum: Python
    Replies:
    4
    Views:
    431
    Jacob Rael
    Apr 15, 2006
  3. Replies:
    2
    Views:
    529
    bruce barker
    Mar 25, 2008
  4. AAaron123
    Replies:
    3
    Views:
    669
    AAaron123
    Jul 28, 2009
  5. Isaac Won
    Replies:
    9
    Views:
    387
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page