[Catalyst] 'require' vs 'use' in Catalyst*

Rodney Broom rbroom+catalyst at rbroom.com
Thu Aug 10 19:54:32 CEST 2006

From: "Joel Bernstein" <joel at fysh.org>

> On Thu, Aug 10, 2006 at 10:28:47AM -0700, Rodney Broom wrote:
> > Disliking the fact that require() doesn't call my import(), I'm trying to figure out why Catalyst (and so many other things) use require() over use(). I have to think there's a good reason that just isn't occuring to me.
> require is runtime, use is compile-time.


> Perl doesn't know at compile-time which plugins you're going to load.

Sorry, I'm missing how that effects the choice of require over use. Plugins are found via Module::Pluggable::Object::plugins() in Catalyst::setup_components(), yes?

The primary (or initial) reason I want use() is because I want my import called from my schema class:

  package MyApp::Schema::Main;

  use base qw(DBIx::Class::Schema);
  sub import {

With require(), I'm forced to call import() explicity in that package.

Under Catalyst, I get all classes. Outside of Catalyst (scripts) I tend to only use what I need:

  # user_maint.pl
  use MyApp::Schema::Main qw(User);
  $schema = MyApp::Schema::Main->new($db_conn_name);

Rodney Broom

More information about the Catalyst mailing list