http://www.perlmonks.org?node_id=506212

sk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I have question on how to parse named parameters. I am trying to build a mini-interpreter, actually a mini code-generator based on some keywords that users put into a text file. Generating the required code is easy once i can get the parameters. Here is an example input

option1 = value0 value1 value2 option3 =value3 value4 option2=value5 # please note that the options might not be in order as you can see ab +ove. Not all options are required to be used.
I would like to store these in a hash with  option1 option2 and option3 as keys with their corresponding values.

I know this problem becomes much easier if the values for the options are quoted something like option1 = "value0 value1 value2". But, it would be great if i could parse the input without forcing the double quote requirement.

My attempt to split on = and then search for keywords made it so complicated messy. The code got ugly and i am not posting it here. Could you guys help me out with some ideas on how to parse this? If this is too complex then i would force the double-quote requirement.

Thanks a lot!

cheers

SK