Server IP : 85.214.239.14 / Your IP : 52.14.7.103 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/cwd/proc/2/root/proc/2/root/proc/3/cwd/usr/share/perl/5.36.0/ |
Upload File : |
package overloading; use warnings; our $VERSION = '0.02'; 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{"($_"} : do { require Carp; 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