b374k
m1n1 1.01
Apache/2.2.15 (CentOS)
Linux obd60-6c49958d75-2q7cw 5.4.0-174-generic #193-Ubuntu SMP Thu Mar 7 14:29:28 UTC 2024 x86_64
uid=48(apache) gid=48(apache) groups=48(apache)
server ip : 172.67.192.52 | your ip : 10.244.126.0
safemode OFF
 >  / usr / share / perl5 /
Filename/usr/share/perl5/overloading.pm
Size1.76 kb
Permissionrw-r--r--
Ownerapache
Create time23-Dec-2025 17:41
Last modified22-Mar-2017 16:32
Last accessed21-Apr-2026 22:53
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
package overloading;
use warnings;

use Carp ();

our $VERSION = '0.01';

my $HINT_NO_AMAGIC = 0x01000000; # see perl.h

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")
} @_;
}

sub import {
my ( $class, @ops ) = @_;

if ( @ops ) {
if ( $^H{overloading} ) {
vec($^H{overloading} , $_, 1) = 0 for _ops_to_nums(@ops);
}

if ( $^H{overloading} !~ /[^\0]/ ) {
delete $^H{overloading};
$^H &= ~$HINT_NO_AMAGIC;
}
} else {
delete $^H{overloading};
$^H &= ~$HINT_NO_AMAGIC;
}
}

sub unimport {
my ( $class, @ops ) = @_;

if ( exists $^H{overloading} or not $^H & $HINT_NO_AMAGIC ) {
if ( @ops ) {
vec($^H{overloading} ||= '', $_, 1) = 1 for _ops_to_nums(@ops);
} else {
delete $^H{overloading};
}
}

$^H |= $HINT_NO_AMAGIC;
}

1;
__END__

=head1 NAME

overloading - perl pragma to lexically control overloading

=head1 SYNOPSIS

{
no overloading;
my $str = "$object"; # doesn't call stringification overload
}

# it's lexical, so this stringifies:
warn "$object";

# it can be enabled per op
no overloading qw("");
warn "$object";

# and also reenabled
use overloading;

=head1 DESCRIPTION

This pragma allows you to lexically disable or enable overloading.

=over 6

=item C<no overloading>

Disables overloading entirely in the current lexical scope.

=item C<no overloading @ops>

Disables only specific overloads in the current lexical scope.

=item C<use overloading>

Reenables overloading in the current lexical scope.

=item C<use overloading @ops>

Reenables overloading only for specific ops in the current lexical scope.

=back

=cut