This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add tests for qr/\p{}/
[perl5.git] / lib / overloading.pm
index 23551de..c762227 100644 (file)
@@ -1,18 +1,18 @@
 package overloading;
 use warnings;
 
-use Carp ();
+our $VERSION = '0.02';
 
-our $VERSION = '0.01';
+my $HINT_NO_AMAGIC = 0x01000000; # see perl.h
 
-require 5.011000;
+require 5.010001;
 
 sub _ops_to_nums {
     require overload::numbers;
 
     map { exists $overload::numbers::names{"($_"}
        ? $overload::numbers::names{"($_"}
-       : Carp::croak("'$_' is not a valid overload")
+       : do { require Carp; Carp::croak("'$_' is not a valid overload") }
     } @_;
 }
 
@@ -26,18 +26,18 @@ sub import {
 
        if ( $^H{overloading} !~ /[^\0]/ ) {
            delete $^H{overloading};
-           $^H &= ~0x01000000;
+           $^H &= ~$HINT_NO_AMAGIC;
        }
     } else {
        delete $^H{overloading};
-       $^H &= ~0x01000000;
+       $^H &= ~$HINT_NO_AMAGIC;
     }
 }
 
 sub unimport {
     my ( $class, @ops ) = @_;
 
-    if ( exists $^H{overloading} or not $^H & 0x01000000 ) {
+    if ( exists $^H{overloading} or not $^H & $HINT_NO_AMAGIC ) {
        if ( @ops ) {
            vec($^H{overloading} ||= '', $_, 1) = 1 for _ops_to_nums(@ops);
        } else {
@@ -45,7 +45,7 @@ sub unimport {
        }
     }
 
-    $^H |= 0x01000000;
+    $^H |= $HINT_NO_AMAGIC;
 }
 
 1;
@@ -59,7 +59,7 @@ overloading - perl pragma to lexically control overloading
 
     {
        no overloading;
-       my $str = "$object"; # doesn't call strirngification overload
+       my $str = "$object"; # doesn't call stringification overload
     }
 
     # it's lexical, so this stringifies:
@@ -67,7 +67,7 @@ overloading - perl pragma to lexically control overloading
 
     # it can be enabled per op
     no overloading qw("");
-    warn "$object"
+    warn "$object";
 
     # and also reenabled
     use overloading;
@@ -84,7 +84,7 @@ Disables overloading entirely in the current lexical scope.
 
 =item C<no overloading @ops>
 
-Disables only specific overloads in the current lexical scopes.
+Disables only specific overloads in the current lexical scope.
 
 =item C<use overloading>