perlperl-core

Ambiguous call resolved as CORE::join(), qualify as such or use & 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?


Solution

  • 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.