Heylo,
I'm experiencing, somewhat of, a conundrum regarding perl script development. I have written a small Perl script using the standard (basic) Perl installation. I have the following setup:
C:\MyScript\perl.pl
C:\MyScript\configuration\config.ini
C:\MyScript\output\output.txt
This is the perl.pl source:
$config = '/configuration/config.ini';
$conf = Config::IniFiles->new( -file => $config_file );
$output_dir = conf->val('output', 'out_dir');
$output_file = "$output_dir/output.txt";
open (out, ">$output_file") || die ("It's not your day mate!");
print out "This is a test...";
close out;
This is the config.ini contents:
[output]
output_dir = C:\MyScript\output
The problem I am having is that the second line ($conf) appears to be having trouble opening the file at that location. As I will be using this script in both a windows and unix environment (without installing any addition modules) I was wondering how I could get around this? What I was hoping was to create a script that would entirely configurable through the config.ini file. The config however, only works if I give it's absolute path, like so:
$config = 'C:\MyScript\configuration\config.ini';
But since this will be deployed to several diverse environments modifying the scripts source is out of the question. What would you guys recommend? How should one approach such a scenario?
Any help and/or advice is greatly appreciated.
All the best, MC