when you say this:
use MODULENAME LISTOFARGS;
this translates into this:
BEGIN
{
require MODULENAME;
MODULENAME->import LISTOFARGS;
}
Somewhere I read that no error is raised
if teh import method does not exist.
I don't know if this applies to ANY call
to an "import" method, or just when it
gets called because of a "use" statement.
according to "programming Perl" 2nd ed.
"there is no built-in import function. it
is merely an ordinary class method defined
by modules that wish to export names to
another module through the use operator."
Method calls won't inherit from class UNIVERSAL,
and you're code had no base class,
so there is no place that perl can be inheriting
it that is non-magical.
my guess is that there is something special
about ANY call to an "import" method such
that no error is raised if it does not exist.
i.e. you found one of those neat
side effects of the auto-magical
characteristics of perl.
hope you didn't spend too much time
trying to debug your code when it was
actually a perl abnormality.
Greg
Ron Newman wrote:
>
> The following program does not cause an error, even though
> my package neither defines a function called import(), nor
> inherits from any other package:
>
> #!/usr/bin/perl -w
> use strict;
>
> package This;
> This->import();
>
> My question: What function is it calling, and where did it
> find that function? Is there a UNIVERSAL::import() which
> does nothing?
>
> --
> Ron Newman [EMAIL PROTECTED]
> URL: http://www2.thecia.net/users/rnewman/
--
Greg London
x7541