This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Extract _handle_source_command.
authorShlomi Fish <shlomif@shlomifish.org>
Sun, 7 Oct 2012 10:11:45 +0000 (12:11 +0200)
committerRicardo Signes <rjbs@cpan.org>
Mon, 12 Nov 2012 14:18:37 +0000 (09:18 -0500)
lib/perl5db.pl

index eeab7e9..c575d8c 100644 (file)
@@ -627,7 +627,6 @@ context, so we can use C<my> freely.
 use vars qw(
     @args
     %break_on_load
-    @cmdfhs
     $CommandSet
     $CreateTTY
     $DBGR
@@ -668,6 +667,7 @@ use vars qw(
 );
 
 our (
+    @cmdfhs,
     $evalarg,
     $frame,
     $hist,
@@ -2880,20 +2880,7 @@ pick it up.
 
 =cut
 
-                # source - read commands from a file (or pipe!) and execute.
-                if (my ($sourced_fn) = $cmd =~ /\Asource\s+(.*\S)/) {
-                    if ( open my $fh, $sourced_fn ) {
-
-                        # Opened OK; stick it in the list of file handles.
-                        push @cmdfhs, $fh;
-                    }
-                    else {
-
-                        # Couldn't open it.
-                        &warn("Can't execute '$sourced_fn': $!\n");
-                    }
-                    next CMD;
-                }
+                $obj->_handle_source_command;
 
                 if (my ($which_cmd, $position)
                     = $cmd =~ /^(enable|disable)\s+(\S+)\s*$/) {
@@ -3865,6 +3852,27 @@ sub _handle_equal_sign_command {
     return;
 }
 
+sub _handle_source_command {
+    my $self = shift;
+
+    # source - read commands from a file (or pipe!) and execute.
+    if (my ($sourced_fn) = $DB::cmd =~ /\Asource\s+(.*\S)/) {
+        if ( open my $fh, $sourced_fn ) {
+
+            # Opened OK; stick it in the list of file handles.
+            push @cmdfhs, $fh;
+        }
+        else {
+
+            # Couldn't open it.
+            DB::warn("Can't execute '$sourced_fn': $!\n");
+        }
+        next CMD;
+    }
+
+    return;
+}
+
 package DB;
 
 # The following code may be executed now: