What approach have you tried so far? Please give us concrete code that we can help with.
A general comment is that you seem to want to parse .ini style files. There is a CPAN module Config::IniFiles that can parse and extract parameter-value pairs for you.