Ambiguous call resolved as CORE::join(), qualify as such or use & at

747 Views Asked by At

I have got the error:

Ambiguous call resolved as CORE::join(), qualify as such or use & at

When I fix error as:

$args =  CORE::join( ', ', @$args );

everything works fine.

But when I fix it as:

$args =  &join( ', ', @$args );

As suggested by error message, I got different error:

Can't locate object method "_make_instance" via package ", " (perhaps you forgot to load ", "?) at

why second fix does not work?

2

There are 2 best solutions below

0
On BEST ANSWER

You are getting the error because you have a sub named join, so you need to disambiguate it. To make it call the built-in, prepend CORE::. To make it call the sub, prepend &.

The error is because you are calling the sub and it is actually a method that is expecting an object or class as the first parameter, which would happen implicitly when you use the method call syntax.

1
On

You're getting that warning because you've defined a subroutine called join. Now Perl isn't sure whether join( ', ', @$args ) is supposed to call the built-in function or your subroutine.

CORE::join unambiguously calls the built-in join.

&join(...) unambiguously calls your subroutine (and overrides any prototype it may have). As for why your subroutine throws bizarre errors about a package called , and _make_instance, we can't answer that if you don't show us the code.