An import method is defined in UNIVERSAL.pm, but that file is not loaded unless it is explicitly requested as use UNIVERSAL; which is very rare practice.
So, how does Perl handle the import method in modules not defining it?
It is a special case:
when in a method call the requested method can not be resolved, perl checks if it is actually import (or unimport) and in that case, the call is just ignored./* excerpt from gv.c in the perl source code */ if (!gv) { if (strEQ(name,"import") || strEQ(name,"unimport")) gv = MUTABLE_GV(&PL_sv_yes); else if (autoload) gv = gv_autoload_pvn( ostash, name, nend - name, GV_AUTOLOAD_ISMETHOD|flags ); if (!gv && do_croak) { /* Right now this is exclusively for the benefit of S_method_c +ommon in pp_hot.c */
In reply to Re^5: Default import function
by salva
in thread Default import function
by Athanasius
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |