On Mon, Dec 25, 2017 at 01:19:59AM -0800, KES wrote: > # New Ticket Created by KES > # Please include the string: [perl #132653] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=132653 > > > > Very often in the program there are consecutive ifs. Like this: > > $x = <>; > > if( !$x ) { > print 1; > } > elsif( $x eq 'asdf' ) { > print 2; > } > elsif( $x ne 'asdf' ) { > print 3; > } > else { > print 4; > } > > And this is unhandy when 's' debugger command skip all ifs and do not stop on each. > For example 'elsif' is skipped on line 8: > > $ perl -d ./t.pl > > Loading DB routines from perl5db.pl version 1.49_04 > Editor support available. > > Enter h or 'h h' for help, or 'man perldebug' for more help. > > main::(./t.pl:3): $x = <>; > DB<1> s > df > main::(./t.pl:5): if( !$x ) { > DB<1> s > main::(./t.pl:12): print 3; > DB<1> > > expected debugging: > > main::(./t.pl:3): $x = <>; > DB<1> s > df > main::(./t.pl:5): if( !$x ) { > DB<1> s > main::(./t.pl:8): elsif( $x eq 'asdf' ) { > DB<1> s > main::(./t.pl:12): print 3; > DB<1> 's' is documented as: Single step. Executes until the beginning of another statement Perl compiles if/else chains into ?: expressions; for example, if (C1) { S1; } elsif (C2) { S2; } elsif (C3) { S3; } else { S4; } gets compiled to the equivalent of: C1 ? do { S1; } : C2 ? do { S2; } : C3 ? do { S3 } : do { S4 }; which the debugger sees as a single expression. -- More than any other time in history, mankind faces a crossroads. One path leads to despair and utter hopelessness. The other, to total extinction. Let us pray we have the wisdom to choose correctly. -- Woody AllenThread Previous | Thread Next