Okay , I'm giving up and asking for help;
I have a script to access info in my MySQL database. I want my credentials buried in a file I can include for security. To make it even I little neater, I tried to create a sub directory (include) in my cgi-bin directory.
This is a simple example omitting all the db stuff (because that's not my problem).
#!/usr/bin/perl
use strict;
use warnings;
$data_base = 'dbi::mysql::test_db';
$db_user = 'some_user';
$db_pw = 'password';
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
require'/include/config.pl';
$param1 = $data_base;
$param2 = $db_user;
$param3 = $db_pw;
our
require
The path you provided in the require
is off: You specified an absolute path, but you mistook the docroot of the server for the actual filesystem root.
/include/config.pl
is anchored at the filesystem root, the same way /usr/bin/perl
is.
./include/config.pl
would be a path relative to the current dir (presumably the cgi-bin
folder) and might work better. If you know the absolute path of the cgi-bin dir, you can use an absolute path: /var/www/whatever/structure/the/host/has/htdocs/cgi-bin/include/config.pl
If you are using a web framework (I hope you are) instead of plain, dated, CGI, there may already be a configuration file present. E.g. Dancer has a YAML file with lots of settings you could expand.