I am on shared hosting server. i have a perl module file which works fine. i can use its subs with no problem from a perl script file. if i add this to pm file,
use DBI;
my $username = "username";
my $password = "password";
my $dsn = "DBD:mysql:database"; # i changed DBD to DBI as well but no good
still everything works fine. but as soon I add the following line to perl module file, the perl script file starts complaining "Compilation failed in require"
my $dbh = DBI->connect($dsn, $username, $password ) or die $DBI::errstr;
I tried googling it but no result. Any idea?
I wanted to create a dbi handle which could be used by the subs of that module but i was getting error before i could use that(as i mentioned in the question). May be it is a security feature of modules, Apprently i can only use dbi in the sub form,
use DBI;
sub databaseHandle{
my $username = "username";
my $password = "password";
my $dsn = "DBI:mysql:database";
my $dbh = DBI->connect($dsn, $username, $password ) or die $DBI::errstr;
return $dbh }
my $dbh = databaseHandle();
i dont know the particular reason but this is how i am using it. Thanks for all the help and idea.