--- perl5db.pl.org 2007-12-18 10:47:07.000000000 +0100 +++ perl5db.pl 2008-09-01 23:02:16.718750000 +0200 @@ -2643,7 +2643,7 @@ demarcation' above which commands can be entered anytime, and below which they can't. -=head4 C - single step, but don't trace down into subs +=head4 C - single step, but don't trace down into subs, and not even into grep/map/sort Done by setting C<$single> to 2, which forces subs to execute straight through when entered (see C). We also save the C command in C<$laststep>, @@ -2655,9 +2655,41 @@ $cmd =~ /^n$/ && do { end_report(), next CMD if $finished and $level <= 1; - # Single step, but don't enter subs. - $single = 2; + if ( $dbline[$line] =~ m{\b( + grep + | + map + | + sort)\b}xms + ) { + # Scan forward to the next executable line + $i = $line; + ++$i; + $max = $#dbline; + ++$i while $dbline[$i] == 0 && $i < $max; + # Check if we would leave the sub + my @sublast = split m{-}xms, $sub{$sub}; + if (($sub eq '' || $i <= $sublast[-1]) + && $dbline[$i] != 0) { + # Next line is in current sub + # or no sub at all + + # Set up the one-time-break sigil. + $dbline{$i} =~ s/($|\0)/;9$1/; # add one-time-only b.p. + + # Clear single stepping flags + $DB::single &= ~3; + } else { + # have no line (oneliner) + # or about to leave the sub... + # Turn on stack tracing one level up. + $stack[ -1 ] |= 1; + } + } else { + # Single step, but don't enter subs. + $single = 2; + } # Save for empty command (repeat last). $laststep = $cmd; last CMD;