after you got sick for several weeks, I'm trying to get back to my screenwriting projects and seem to be facing a newbie at speed.
I am trying to build a script to cut a file, and then process the parameters from the file using regex and build a hash from the found parameters.
But the problem that I am facing is that the hash is not built in the way I want it, or at least I think it is not.
Here is a tiny script I'm working on.
use strict;
use warnings;
use File::Slurp;
use Data::Dumper;
my %config;
my $text = read_file("./config/settings.cfg");
if ($text =~ /^esxi\.host\s+=\s+(?<host>.+)/xm) {
$config{host} = "$+{host}";
}
print Dumper (%config);
For those wishing to execute a script, here is the configuration file that I create
Connection Options:
esxi.host = server01
esxi.port = 22
esxi.username = root
esxi.password = password
Backup Options:
Compression Options:
0 = none
1 = tar
2 = gzip
3 = tar+gzip
backup.compression = 0
Just save it in a file with a name settings.cfgif you do not want to change the parameter in the script.
Anyway, this is the result that I get from Data::Dumper.
$VAR1 = 'server01';
$VAR2 = {
'host' => 'esxi01'
};
, , server01 host , , .
( ), , , .