in reply to Re: PDL and srand puzzle
in thread PDL and srand puzzle

I guess that the call to sqrt gets compiled to CORE::sqrt before the interpreter processes your subroutine declaration. You can get the warning about the ambiguity if you declare your subroutine before calling sqrt (I got rid of the percent format because it breaks shell syntax on Linux):

perl -wle "sub sqrt { return q(more than 1.4) } print sqrt(2);print ma +in::sqrt(2); print CORE::sqrt(2);"
That prints:
Ambiguous call resolved as CORE::sqrt(), qualify as such or use & at - +e line 1. 1.4142135623731 more than 1.4 1.4142135623731

Replies are listed 'Best First'.
Re^3: PDL and srand puzzle
by syphilis (Archbishop) on Jun 05, 2024 at 07:49 UTC
    Ambiguous call resolved as CORE::sqrt(), qualify as such or use & at -e line 1.

    Thanks. I had tried pre-declaring the sub but I must have stuffed up that test because I certainly didn't see that warning.
    I've just double-checked, and the warning is present for me, too.

    Update: Oh ... and for the warning to appear, the ambiguity has to be detected at compile time.

    Cheers,
    Rob.