diff options
author | Shlomi Fish <shlomif@shlomifish.org> | 2012-11-11 19:11:56 +0200 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2013-01-02 11:21:57 +1100 |
commit | 4886a4695752d717aefb72af970002a2f8fcf776 (patch) | |
tree | 968a7b7d0d71f4e95af93c8861442ef82f17dcce /lib | |
parent | 5f0d5f290cd741c8925786daeecf45cb1ba37e0a (diff) | |
download | perl-4886a4695752d717aefb72af970002a2f8fcf776.tar.gz |
Extract a subroutine.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/perl5db.pl | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/lib/perl5db.pl b/lib/perl5db.pl index 6ef86acc18..516926723b 100644 --- a/lib/perl5db.pl +++ b/lib/perl5db.pl @@ -5456,6 +5456,28 @@ sub _minify_to_max { return; } +sub _cmd_l_handle_var_name { + my $var_name = shift; + + $evalarg = $var_name; + + my ($s) = DB::eval(); + + # Ooops. Bad scalar. + if ($@) { + print {$OUT} "Error: $@\n"; + next CMD; + } + + # Good scalar. If it's a reference, find what it points to. + $s = CvGV_name($s); + print {$OUT} "Interpreted as: $1 $s\n"; + $line = "$1 $s"; + + # Call self recursively to really do the command. + return cmd_l( 'l', $s ); +} + sub cmd_l { my $current_line = $line; my $cmd = shift; @@ -5467,23 +5489,8 @@ sub cmd_l { # If the line is '$something', assume this is a scalar containing a # line number. # Set up for DB::eval() - evaluate in *user* context. - if ( ($evalarg) = $line =~ /\A(\$.*)/s ) { - - my ($s) = DB::eval(); - - # Ooops. Bad scalar. - if ($@) { - print {$OUT} "Error: $@\n"; - next CMD; - } - - # Good scalar. If it's a reference, find what it points to. - $s = CvGV_name($s); - print {$OUT} "Interpreted as: $1 $s\n"; - $line = "$1 $s"; - - # Call self recursively to really do the command. - return cmd_l( 'l', $s ); + if ( my ($var_name) = $line =~ /\A(\$.*)/s ) { + return _cmd_l_handle_var_name($var_name); } ## end if ($line =~ /^(\$.*)/s) # l name. Try to find a sub by that name. |