Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Setting break point for particular condition in the subroutine

by rjt (Deacon)
on Mar 07, 2013 at 08:15 UTC ( #1022167=note: print w/ replies, xml ) Need Help??


in reply to Setting break point for particular condition in the subroutine

It sounds like you want to insert the breakpoint at the if ($cmd =~ /INITIAL/i) line. Let's say that's line 123. Then, type:

b 123 $cmd =~ /INITIAL/i

Setting it to the subroutine entry is problematic because $cmd isn't set yet (or at least isn't set to a member of @commands. In addition to that, simply using /INITIAL/i as your condition would be running that regexp on $_, not $cmd.

See perldebug for more info.


Comment on Re: Setting break point for particular condition in the subroutine
Select or Download Code
Replies are listed 'Best First'.
Re^2: Setting break point for particular condition in the subroutine
by srlbharu (Acolyte) on Mar 07, 2013 at 09:04 UTC

    This subroutine is called from other subroutine which is intern called from my perl script. So setting break point b 123 $cmd =~ /INITIAL/i throws error Line 118 not breakable. because my script does not have those many lines.

    From the google docs I found the below statement b subname [condition] Can we use this in anyway?

      Yes, that's why you need to figure out the actual line number. "123" was just an example. You can determine the line number with l Engine::_Execute ... lines that are breakable will show with a colon (:) after the line number in the debugger. Hence, if you see this:

      100 sub Engine::Execute 101 { 102 103: foreach (@commands) 104 { 105: $cmd = $_; 106: if($cmd =~ /INITIAL/i) 107 {

      ... then you would type b 106 $cmd =~ /INITIAL/i

      Again, these numbers are just examples. You need to determine the actual line number for yourself with l Engine::_Execute!

      > From the google docs I found the below statement b subname [condition] Can we use this in anyway?

      No and I already showed you two ways to solve this. Why didn't you try?

      Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1022167]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (13)
As of 2015-07-07 18:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls