This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Extract a common subroutine.
authorShlomi Fish <shlomif@shlomifish.org>
Thu, 13 Sep 2012 11:41:59 +0000 (14:41 +0300)
committerRicardo Signes <rjbs@cpan.org>
Mon, 12 Nov 2012 14:18:22 +0000 (09:18 -0500)
lib/perl5db.t

index d612b6e..5b60c54 100644 (file)
@@ -356,7 +356,7 @@ package main;
     );
 }
 
-sub _calc_new_var_wrapper
+sub _calc_generic_wrapper
 {
     my $args = shift;
 
@@ -365,6 +365,18 @@ sub _calc_new_var_wrapper
     local $ENV{PERLDB_OPTS} = "ReadLine=0" . $extra_opts;
     return DebugWrap->new(
         {
+            cmds => delete($args->{cmds}),
+            prog => delete($args->{prog}),
+            %$args,
+        }
+    );
+}
+
+sub _calc_new_var_wrapper
+{
+    my ($args) = @_;
+    return _calc_generic_wrapper(
+        {
             cmds =>
             [
                 'b 23',
@@ -373,7 +385,6 @@ sub _calc_new_var_wrapper
                 'x "new_var = <$new_var>\\n"',
                 'q',
             ],
-            prog => delete($args->{prog}),
             %$args,
         }
     );
@@ -479,12 +490,9 @@ SKIP:
 
 sub _calc_trace_wrapper
 {
-    my $args = shift;
+    my ($args) = @_;
 
-    my $extra_opts = delete($args->{extra_opts});
-    $extra_opts ||= '';
-    local $ENV{PERLDB_OPTS} = "ReadLine=0" . $extra_opts;
-    return DebugWrap->new(
+    return _calc_generic_wrapper(
         {
             cmds =>
             [
@@ -492,7 +500,6 @@ sub _calc_trace_wrapper
                 'c',
                 'q',
             ],
-            prog => delete($args->{prog}),
             %$args,
         }
     );