I have come up with the following, to first read the file and then put it into hash. =
sign used as a delimiter.
sub get_config_value_by_key {
my ( $module, $key ) = @_;
my $config = &read_file_contents(
$config_directory . '/' . $module . '/config' );
my %config = $config =~ /(.*)=(.*)/g;
return $config{$key};
}
It works fine, except that, if I have equal sign in the value (which I use as delimiter), then it doesn't parse it correctly.
How to fix my regex to make it work properly, escaping =
signs in the value?
Example of config lines:
key_1=Some value
key_2=Some value with = sign which breaks it.