summaryrefslogtreecommitdiff
path: root/lib/perl5db.pl
diff options
context:
space:
mode:
authorShlomi Fish <shlomif@shlomifish.org>2012-11-14 13:19:50 +0200
committerTony Cook <tony@develop-help.com>2013-01-02 11:22:02 +1100
commitd0bfb56c17bf64c9c527608ddc40b8b24d944b39 (patch)
tree77489a183406279c1e4b13de30275ba24fe73108 /lib/perl5db.pl
parentfb73dc2fcc96a4a5edf1daa66f0114b4b2b6a196 (diff)
downloadperl-d0bfb56c17bf64c9c527608ddc40b8b24d944b39.tar.gz
Extract some duplicate code into a closure.
Diffstat (limited to 'lib/perl5db.pl')
-rw-r--r--lib/perl5db.pl39
1 files changed, 18 insertions, 21 deletions
diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index 070c92e108..9574084c92 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -5735,6 +5735,22 @@ sub cmd_L {
my ($action_wanted, $break_wanted, $watch_wanted) =
_cmd_L_calc_wanted_flags(shift);
+ my $handle_db_line = sub {
+ my ($l) = @_;
+
+ my ( $stop, $action ) = split( /\0/, $l );
+
+ if ($stop and $break_wanted) {
+ print {$OUT} " break if (", $stop, ")\n"
+ }
+
+ if ($action && $action_wanted) {
+ print {$OUT} " action: ", $action, "\n"
+ }
+
+ return;
+ };
+
# Breaks and actions are found together, so we look in the same place
# for both.
if ( $break_wanted or $action_wanted ) {
@@ -5765,18 +5781,7 @@ sub cmd_L {
# Print the line.
print {$OUT} " $i:\t", $dbline[$i];
- # Pull out the condition and the action.
- my ( $stop, $action ) = split( /\0/, $dbline{$i} );
-
- # Print the break if there is one and it's wanted.
- if ($stop && $break_wanted) {
- print {$OUT} " break if (", $stop, ")\n";
- }
-
- # Print the action if there is one and it's wanted.
- if ($action && $action_wanted) {
- print {$OUT} " action: ", $action, "\n";
- }
+ $handle_db_line->($dbline{$i});
# Quit if the user hit interrupt.
if ($signal) {
@@ -5815,15 +5820,7 @@ sub cmd_L {
for my $line ( sort { $a <=> $b } keys %$db ) {
print {$OUT} " $line:\n";
- my ( $stop, $action ) = split( /\0/, $$db{$line} );
-
- if ($stop and $break_wanted) {
- print {$OUT} " break if (", $stop, ")\n"
- }
-
- if ($action && $action_wanted) {
- print {$OUT} " action: ", $action, "\n"
- }
+ $handle_db_line->($db->{$line});
if ($signal) {
last POSTPONED_SCANS;