Reputation: 1231
Hi I am relativley new to Perl and DBI programming, and just started learning CGI. I want to access a Mysql databases via a perl cgi script but I dont want to store the configuration variables (username , password etc ) in the actual script in the cgi-bin. I can use a require '/path/to/configfile.pl'
statement but only without using use strict
, which I dont like.
I am hoping someone can tell me what is the correct and safe way for including
config files in this specific situation.
Upvotes: 1
Views: 1054
Reputation: 4709
If you are using Mysql,then this will work:
my $dbh = DBI->connect("dbi:mysql:mysql_read_default_file=$config_file;mysql_read_default_group=$group",undef,undef,{});
And the config file should be like this:
[group_name]
database=my_db
host=X.X.X.X
user=my_user
password=my_password
port=XXXX
[another_group]
...
Upvotes: 0