Perl Programming Question:

Download Job Interview Questions and Answers PDF

Why does Perl not have overloaded functions?

Perl Programming Interview Question
Perl Programming Interview Question

Answer:

Because you can inspect the argument count, return context, and object types all by yourself.
In Perl, the number of arguments is trivially available to a function via the scalar sense of @_, the return context via wantarray(), and the types of the arguments via ref() if they're references and simple pattern matching like /^d+$/ otherwise. In languages like C++ where you can't do this, you simply must resort to overloading of functions.

Download Perl Programming Interview Questions And Answers PDF

Previous QuestionNext Question
What does $result = f() .. g() really return?What does read() return at end of file?