Reputation: 219
unless defined(&dl_load_file);
The above looks ambiguous to me but actually works .
How does Perl know whether or not to call dl_load_file
here?
Upvotes: 2
Views: 244
Reputation: 62109
It's just a special case in Perl's syntax. If you have either defined(&identifier)
or defined &identifier
, it checks for the existence of a subroutine named identifier
without calling it, even though &identifier
would normally call the subroutine.
defined &identifier()
, on the other hand, does call the subroutine and then test its return value. The parens after identifier make it a function call.
Upvotes: 4
Reputation: 26871
I think there is not a call - is just a check to see if that function is defined or not
Perl interpreter knows this with the help of Symbol Tables
Upvotes: 0