Phoenix.pm: Parameter parser
Eden Li
eden.li at asu.edu
Tue Nov 26 14:39:08 CST 2002
UNTESTED:
use Parse::RecDescent;
my (%params) = ();
my ($parser) = new Parse::RecDescent (<<HERE);
param: /\w+/ = rhs
{ $params{$item[0]} = $item[1] || 1 }
rhs: /\w+/ | /"(?:\w+\\"?)?"/
HERE
for (@ARGV)
{
$parser->param ($_)
}
# %params now contains parameters
:)
eden
From: "Doug Miles" <doug.miles at bpxinternet.com>
> I just implemented a parser that takes something like this:
>
> command param1 param2="value2" param3="value3 \"foo\""
>
> and puts the parameters and values into a hash. The value for param1
> would be "1". I'm not sure I implemented it the best way, though. I
> thought I'd get some ideas from you folks to get a different
> perspective. I'll post what I did after I get some responses. I don't
> want to contaminate your thinking. :)
>
>
More information about the Phoenix-pm
mailing list