8 my $HINT_NO_AMAGIC = 0x01000000; # see perl.h
13 require overload::numbers;
15 map { exists $overload::numbers::names{"($_"}
16 ? $overload::numbers::names{"($_"}
17 : Carp::croak("'$_' is not a valid overload")
22 my ( $class, @ops ) = @_;
25 if ( $^H{overloading} ) {
26 vec($^H{overloading} , $_, 1) = 0 for _ops_to_nums(@ops);
29 if ( $^H{overloading} !~ /[^\0]/ ) {
30 delete $^H{overloading};
31 $^H &= ~$HINT_NO_AMAGIC;
34 delete $^H{overloading};
35 $^H &= ~$HINT_NO_AMAGIC;
40 my ( $class, @ops ) = @_;
42 if ( exists $^H{overloading} or not $^H & $HINT_NO_AMAGIC ) {
44 vec($^H{overloading} ||= '', $_, 1) = 1 for _ops_to_nums(@ops);
46 delete $^H{overloading};
50 $^H |= $HINT_NO_AMAGIC;
58 overloading - perl pragma to lexically control overloading
64 my $str = "$object"; # doesn't call stringification overload
67 # it's lexical, so this stringifies:
70 # it can be enabled per op
71 no overloading qw("");
79 This pragma allows you to lexically disable or enable overloading.
83 =item C<no overloading>
85 Disables overloading entirely in the current lexical scope.
87 =item C<no overloading @ops>
89 Disables only specific overloads in the current lexical scope.
91 =item C<use overloading>
93 Reenables overloading in the current lexical scope.
95 =item C<use overloading @ops>
97 Reenables overloading only for specific ops in the current lexical scope.