sk has asked for the wisdom of the Perl Monks concerning the following question:
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
I would like to store these in a hash with option1 option2 and option3 as keys with their corresponding values.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 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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Parsing named parameters
by sauoq (Abbot) on Nov 07, 2005 at 02:52 UTC | |
by sk (Curate) on Nov 07, 2005 at 03:32 UTC | |
Re: Parsing named parameters
by pg (Canon) on Nov 07, 2005 at 03:23 UTC | |
Re: Parsing named parameters
by QM (Parson) on Nov 07, 2005 at 03:11 UTC | |
Re: Parsing named parameters
by samizdat (Vicar) on Nov 07, 2005 at 14:43 UTC | |
Re: Parsing named parameters
by robin (Chaplain) on Nov 07, 2005 at 14:58 UTC | |
by robin (Chaplain) on Nov 07, 2005 at 15:12 UTC | |
by BrowserUk (Patriarch) on Nov 07, 2005 at 15:18 UTC | |
by robin (Chaplain) on Nov 07, 2005 at 15:28 UTC | |
by BrowserUk (Patriarch) on Nov 07, 2005 at 15:30 UTC | |
| |
Re: Parsing named parameters
by chibiryuu (Beadle) on Nov 07, 2005 at 16:42 UTC |