[erlang-questions] Simple (dumb :) pattern matching question

Christian S <>
Thu Dec 14 14:20:33 CET 2006


       parse_post(Arg)
              This  function  will  parse  the  POST data as supplied from the
              browser.  It will return a {Key, Value} list of the items set by
              the browser.

So your variable 'R' is a list (not a tuple), you want to find the
tuple in the list whose 1st element is "formsend".

{value, {_, FormSend}} = lists:keysearch("formsend", 1, R)

You can also filter it out using list comprehensions, if there are
multiple occurences:

[{Key, Val} || {Key, Val} <- R, Key == "formsend"]

I dont understand your code and what you figured it would do.

On 12/14/06, Pat e <> wrote:
> How can i put a pattern match from a yaws form:
>
> {"formsend","process data"} where i want to extract "process data" from list:
>
> out(A) ->
>
>         R = yaws_api:parse_post(A),
>         P(H) = ({I,H} = {R}),
>         L = mnesia:dirty_read(test,R),
>         {html, f("~p", [P])}.
>
> P(H) line gives a statement: "illegal pattern" in yaws and nothing else?? (:(
>
> I looked at the doc's but unfortunately i can't understand the right
> way to go... for simple pattern matching there is only REPL sample:
>
> 5> {X, Y} = {2, 3}.
> {2,3}
> 6> Y.
> 3
>
> .... how do i have to form it in editor?
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list