[Chicago-talk] Why do I need "use"
lembark at wrkhors.com
Wed Mar 1 14:45:04 PST 2006
-- Jay Strauss <me at heyjay.com>
> there was a message on the DBI user list, where the guy wanted to know
> how to solve:
> Can't locate object method "connect" via package "DBI" (perhaps you
> forgot to load "DBI"?) at...
> My question is: Why do you have to use "use"? Perl is so forgiving in
> many cases, and you can load modules at runtime. Why doesn't Perl just
> automatically load modules it discovers in the source?
DBI will load the DBD modules for you, but Perl has to
have seen the constructor for DBI once in order for
you to call:
DBI->connect( ... );
You don't really have to "use" DBI: you could require it
but most people are used to using modules and having the
deed done early is helpful.
Steven Lembark 85-09 90th Street
Workhorse Computing Woodhaven, NY 11421
lembark at wrkhors.com 1 888 359 3508
More information about the Chicago-talk