Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi there,

I've just started using Komodo IDE's trial version and wondered if anybody else was having this same problem.

I can get it to run my whole script without a problem, but when I try to step through the script one line at a time, it gets stuck in a while loop I am using to print out the keys and values of a hash variable. Example code as follows:

print "Original values of thishash:\n"; while (($key, $value) = each(%thishash)){ print $key.", ".$value."\n"; }

When stepping through, it gets to this second print line, and then when pressing the "Step into the code at the current line" button, or the "Step over any code on the current line" button, it just prints the first key/value pair again, and never gets any further than this.

Is this a bug? If so, is it a known bug? If so, is there a known solution? I am running on a Windows 7 Pro 64bit machine if that matters.

  • Comment on Komodo IDE debug gets stuck in while loop when single stepping through
  • Download Code

Replies are listed 'Best First'.
Re: Komodo IDE debug gets stuck in while loop when single stepping through
by Anonymous Monk on Jul 09, 2011 at 15:07 UTC

    Is this a bug? If so, is it a known bug?

    No, this is not a bug, it is a loop, and it is known that loops loop :)

    I believe those komodo menu entries correspond to these two perldebug commands

     s [expr]    Single step [in expr] will loop in loops

     n [expr]    Next, steps over subs will loop in loops

    If so, is there a known solution?

    Yes, use  c [ln|sub]  Continue until position to skip the loop.

    Here is a sample session

    $ cat perldebug.loop.pl #!/usr/bin/perl -- my %f = ( 1 .. 10 ); while(my($k,$v)=each%f){ print qq[$k $v\n]; } print "done\n"; $ perl -d perldebug.loop.pl Loading DB routines from perl5db.pl version 1.33 Editor support available. Enter h or `h h' for help, or `perldoc perldebug' for more help. main::(perldebug.loop.pl:2): my %f = ( 1 .. 10 ); DB<1> n main::(perldebug.loop.pl:3): while(my($k,$v)=each%f){ DB<1> n main::(perldebug.loop.pl:4): print qq[$k $v\n]; DB<1> n 1 2 main::(perldebug.loop.pl:4): print qq[$k $v\n]; DB<1> s 3 4 main::(perldebug.loop.pl:4): print qq[$k $v\n]; DB<1> v 1 #!/usr/bin/perl -- 2: my %f = ( 1 .. 10 ); 3: while(my($k,$v)=each%f){ 4==> print qq[$k $v\n]; 5 } 6: print "done\n"; DB<1> c 5 Line 5 not breakable. DB<2> c 6 7 8 9 10 5 6 main::(perldebug.loop.pl:6): print "done\n"; DB<3> q

      I don't follow what you've done there... I don't want to skip the loop, I'd like the step by step debugging process to follow the script like it does when it runs through the whole thing, as would be logical. Is there any way to do this?

        I don't follow what you've done there...

        What are you confused by the "$ " or "cat"? "$ " is like C:\> and cat is like type -- its a shell (cmd.exe) session , you should try it yourself

        I don't want to skip the loop, I'd like the step by step debugging process to follow the script like it does when it runs through the whole thing, as would be logical. Is there any way to do this?

        Wait a minute, I missed something :) Are you sure the key/value pairs are always the same? Maybe there is whitespace or \r ...

        Is %thishash tied?

        Which version of komodo are you using? Try http://community.activestate.com/forums/komodo/komodo-support

      Guys, I have encountered the same problem, both in Padre and in EPIC on Eclipse. To put in succinctly: when single-stepping through a "while - each -hash" loop:

      while ( ($key, $value) = each %hash ) { print "$key => $value\n"; }
      the debugger gets into an infinite loop, and does not advance the iterator. I found out that this problem has been already mentioned here (in 2006): using-each-hash-debug

      Has anyone found a fix? I am researching it.

        Guys, I have encountered the same problem ...

        I doubt it

        The bug report is marked as resolved