| Eric Teuber 2005-02-10, 8:55 pm |
| George Bouras wrote:
> # try this
>
> {local$/=undef;$_=<DATA>}
> s/[\n\r]//g;
> s/\s*([\(\)=]+)\s*/$1/g;
> s/\(([^=]+)\)/$1/g;
> s/\)\((.+)\)/\)$1/g;
> s/\(/{/g;
> s/\)/}/g;
> s/=/=>/g;
> s/}/},/g;
>
> eval "our \%hash=($_)";
> print $hash{'net_service_name'}{'CONNECT_DATA'
}{'SERVICE_NAME'} ,"\n" ;
> print $hash{'net_service_name'}{'DESCRIPTION'}
{'ADDRESS'};
>
>
>
>
> __DATA__
>
>
>
>
> net_service_name=
> (DESCRIPTION=
> (ADDRESS=(protocol_address_information))
> (CONNECT_DATA=
> (SERVICE_NAME=service_name))
> )
> SOME_OPTION=some_value
>
>
Thanks George,
and Sorry, 'cause my post was not quite right. i posted
[color=darkred]
but as you already noticed the structure should be like this:
'net_service_name' => {
'DESCRIPTION' => {
'CONNECT_DATA' => {
'SERVICE_NAME' => 'service_name'
}
'ADDRESS' => 'protocol_address_information'
}
}
'SOME_OPTION' => 'some_value'
Your solution is working very well for the first key "net_service_name"
but not for the second "SOME_OPTION".
Another problem could be a random order of comments in the configuration
file like this:
net_service_name=
(DESCRIPTION=
(ADDRESS=(protocol_address_information))
# information
(CONNECT_DATA= # nonsense info
(SERVICE_NAME=service_name))
)
# something more
SOME_OPTION=some_value
.... aso.
Surely i could just throw away these comments, but that would not be a
gentle way.
Background of the problem is to find a procedure to read these
configurations of more than 100 systems, modify them and write them back
to the file automatically, if one or more of these settings change at
the ldap server. Also all configurations look different, but may have
same entries.
However, You gave me a new inspiration. I did not think of a way like
that. I will work on a final solution and come back later to the thread
with or -hopefully not- without a solution.
Thanks again,
Eric
|