package overload;
-our $VERSION = '1.19';
+our $VERSION = '1.20';
%ops = (
with_assign => "+ - * / % ** << >> x .",
$package = shift;
my %arg = @_;
my ($sub, $fb);
- *{$package . "::()"} = \&nil; # Make it findable via fetchmethod.
+ *{$package . "::(("} = \&nil; # Make it findable via fetchmethod.
for (keys %arg) {
if ($_ eq 'fallback') {
- for my $sym (*{$package . "::(fallback"}) {
+ for my $sym (*{$package . "::()"}) {
*$sym = \&nil; # Make it findable via fetchmethod.
$$sym = $arg{$_};
}
warnings::warnif("overload arg '$_' is invalid")
unless $ops_seen{$_};
$sub = $arg{$_};
- if (not ref $sub and $sub !~ /::/) {
+ if (not ref $sub) {
$ {$package . "::(" . $_} = $sub;
$sub = \&nil;
}
sub unimport {
$package = (caller())[0];
shift;
+ *{$package . "::(("} = \&nil;
for (@_) {
warnings::warnif("overload arg '$_' is invalid")
unless $ops_seen{$_};
- delete $ {$package . "::"}{"(" . $_};
+ delete $ {$package . "::"}{$_ eq 'fallback' ? '()' : "(" .$_};
}
}
sub Overloaded {
my $package = shift;
$package = ref $package if ref $package;
- mycan ($package, '()');
+ mycan ($package, '()') || mycan ($package, '((');
}
sub ov_method {
for both the I<read-filehandle> syntax C<E<lt>$varE<gt>> and
I<globbing> syntax C<E<lt>${var}E<gt>>.
-B<BUGS> Even in list context, the iterator is currently called only
-once and with scalar context.
-
=item * I<File tests>
The key C<'-X'> is used to specify a subroutine to handle all the
=item *
-No warning is issued for invalid C<use overload> keys.
-Such errors are not always obvious:
-
- use overload "+0" => sub { ...; }, # should be "0+"
- "not" => sub { ...; }; # should be "!"
-
-(Bug #74098)
-
-=item *
-
A pitfall when fallback is TRUE and Perl resorts to a built-in
implementation of an operator is that some operators have more
than one semantic, for example C<|>: