in reply to Loading class

It works because use acts more like this:

BEGIN { require Employee; Employee->import() if Employee->can("import"); }

If your module doesn't have an import, or doesn't inherit from something that does, then the call is skipped.

Replies are listed 'Best First'.
Re: Re: Loading class
by IlyaM (Parson) on Mar 07, 2003 at 13:51 UTC
    Perl seems to do some magic with import method call. Even if you don't define it always work:
    $ perl -e 'XXX->xxx' Can't locate object method "xxx" via package "XXX" (perhaps you forgot + to load "XXX"?) at -e line 1. $ perl -e 'XXX->import' # no error

    --
    Ilya Martynov, ilya@iponweb.net
    CTO IPonWEB (UK) Ltd
    Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net
    Personal website - http://martynov.org

      Perl seems to do some magic with import method call
      Indeedey, perl does some groovy AUTOLOAD magic at the source level. See. import() magic for more info on the matter.
      HTH

      _________
      broquaint