How import and AUTOLOAD Work
Perl follows the following algorithm when you call the function:
package–>method()
First, it looks in the package for the given method. Then it searches through all the methods in all the packages specified by the @ISA array.
Next, it searches for an AUTOLOAD method using the same search algorithm. If it finds one, it calls it using the statement
package–>AUTOLOAD(package, method, arguments);
Remember that Perl is an interpreted language. It is entirely possible to define a new subroutine during the middle of a program’s execution. The AUTOLOAD method facilitates this process. The idea is that if you don’t have a method defined, you can use the AUTOLOAD method to define it and then execute it.
The reason Perl lets ...
Get Perl for C Programmers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.