View Single Post
  #4 (permalink)  
Old 04-28-10, 19:36
sco08y sco08y is offline
Registered User
 
Join Date: Oct 2002
Location: Baghdad, Iraq
Posts: 697
Sorry, I haven't been on dbforums in a while.

Yeah, move the package statement to the beginning if you want DBI to be visible to your classes. What's happening is that at the top of the file, the namespace is automatically "main", so use DBI loads the DBI class into main:: DBI. But then package WacidCon changes the default namespace to WacidCon. So now when you say DBI->connect, it looks for WacidCon:: DBI, but that is undefined.

A small issue, most of the time it's preferable to "use" a module rather than "require" it.

So I'd change the first few lines to look like this:

Code:
package WacidCon;

use DBI;

# You can keep the require statements, but this is a better style
# for most modules.
use lib '.'; # Tells Perl to look in the current directory for modules
use wacid_constant; # You'll need to rename it .pm
use wacid_conf;
And rename those .pl files to .pm. See perldoc lib and perldoc perlmod for more information.

Last edited by sco08y; 04-28-10 at 19:38. Reason: Eliminate random smilies.
Reply With Quote