[Bps-public-commit] Carp-REPL branch, master, updated. 089c1ed7e76d0166cf58afea6a7c7fc3a2cfa81e

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Apr 27 08:06:10 EDT 2009


The branch, master has been updated
       via  089c1ed7e76d0166cf58afea6a7c7fc3a2cfa81e (commit)
       via  1ced03b86f6a24c82485e767686b29a48fd82816 (commit)
      from  8150b48f4b17c472792a5de45025cfc6fd85c3c8 (commit)

Summary of changes:
 lib/Carp/REPL.pm |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit 1ced03b86f6a24c82485e767686b29a48fd82816
Author: sunnavy <sunnavy at gmail.com>
Date:   Mon Apr 27 14:43:16 2009 +0800

    fix the 'repl' can't be exported bug

diff --git a/lib/Carp/REPL.pm b/lib/Carp/REPL.pm
index 378b3fc..a974d6d 100644
--- a/lib/Carp/REPL.pm
+++ b/lib/Carp/REPL.pm
@@ -15,6 +15,12 @@ sub import {
     my $warn   = grep { $_ eq 'warn'     } @_;
     my $test   = grep { $_ eq 'test'     } @_;
     $noprofile = grep { $_ eq 'noprofile'} @_;
+    my $repl   = grep { $_ eq 'repl'     } @_;
+
+    if ( $repl ) {
+        # undef is $package var that Exporter doesn't make use of (yet)
+        __PACKAGE__->export_to_level( 1, undef, 'repl' ); 
+    }
 
     $SIG{__DIE__}  = \&repl unless $nodie;
     $SIG{__WARN__} = \&repl if $warn;

commit 089c1ed7e76d0166cf58afea6a7c7fc3a2cfa81e
Author: sunnavy <sunnavy at gmail.com>
Date:   Mon Apr 27 20:04:41 2009 +0800

    convert code using Exporter => Sub::Exporter

diff --git a/lib/Carp/REPL.pm b/lib/Carp/REPL.pm
index a974d6d..b44d604 100644
--- a/lib/Carp/REPL.pm
+++ b/lib/Carp/REPL.pm
@@ -4,9 +4,6 @@ use warnings;
 use 5.6.0;
 our $VERSION = '0.14';
 
-use base 'Exporter';
-our @EXPORT_OK = 'repl';
-
 our $noprofile = 0;
 our $bottom_frame = 0;
 
@@ -17,11 +14,26 @@ sub import {
     $noprofile = grep { $_ eq 'noprofile'} @_;
     my $repl   = grep { $_ eq 'repl'     } @_;
 
-    if ( $repl ) {
-        # undef is $package var that Exporter doesn't make use of (yet)
-        __PACKAGE__->export_to_level( 1, undef, 'repl' ); 
-    }
+    if ($repl) {
+
+        require Sub::Exporter;
+        my $import_repl = Sub::Exporter::build_exporter(
+            {
+                exports    => ['repl'],
+                into_level => 1,
+            }
+        );
 
+        # get option of 'repl'
+        my $seen;
+        my ($maybe_option) = grep { $seen || $_ eq 'repl' && $seen++ } @_;
+
+        # now do the real 'repl' import
+        $import_repl->( __PACKAGE__, 'repl',
+            ref $maybe_option ? $maybe_option : ()
+        );
+    }
+    
     $SIG{__DIE__}  = \&repl unless $nodie;
     $SIG{__WARN__} = \&repl if $warn;
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list