Ovid@OT-D1 ~
$ perl -e '$x=bless{}, "Foo";$x->import;print "Defined" if defined &Fo
+o::import'
Ovid@OT-D1 ~
$ perl -e 'print "Defined" if defined &UNIVERSAL::isa'
Defined
As you can see from the above snippet, even though we call an import method, none is actually defined in %Foo::. I threw in the %UNIVERSAL:: test so you can see how that test works. Here's proof that it is "special". Note that the call to the non-existent method &Foo::import is successful, but the second call to a non-existent method is not.
$ perl -e '$x=bless{}, "Foo";$x->import;$x->no_way'
Can't locate object method "no_way" via package "Foo" (perhaps you for
+got to load "Foo"?) at -e line 1.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats. |