in reply to Re: List::BinarySearch and conditional tests with Test::More
in thread List::BinarySearch and conditional tests with Test::More

Thank you tobyink.

Anyway, I thought that the idiom of calling a function with ampersand as something not used anymore.

Doing a bit of reasearch I found this blog. As I'm always calling a function with "()" I never had any problem with that.

Anyway... why the & operator is needed in this case? Since I already imported the module with require the code of the function should be already available...

Alceu Rodrigues de Freitas Junior
---------------------------------
"You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill

Replies are listed 'Best First'.
Re^3: List::BinarySearch and conditional tests with Test::More
by tobyink (Canon) on Dec 01, 2014 at 07:51 UTC

    Prototypes alter how a function call is parsed, but need to do so at compile time. So the interpretation of the function call depends on whether List::BinarySearch has already been loaded or not at the time your call to it is compiled.

    Because you don't know whether or not List::BinarySearch, it is safer to avoid the issue by bypassing prototypes (which is what the & does).