[erlang-questions] Re: How to remove \ from string
Joe Armstrong
erlang@REDACTED
Thu Apr 7 08:04:43 CEST 2011
On Wed, Apr 6, 2011 at 11:50 PM, Wes James <comptekki@REDACTED> wrote:
> On Wed, Apr 6, 2011 at 2:07 PM, Muhammad Yousaf
> <muhammad.yousaf@REDACTED> wrote:
> >
> > Thank you i got your point but what i am trying to do is , remote
> computer
> > is sending me a data via socket like {get,"user","wilson","lname"}
> > but for some reason i cannot match it in case statement my output is
>
>
Is the remote computer also running erlang?
If so there is a much simpler way of doing things
/Joe
> <snip>
>
> >
> > Code is as fellow
> > do_echo(Socket) ->
> > case gen_tcp:recv(Socket, 0) of
> > {ok, Data} ->
> > D = binary_to_list(Data),
> > case D of
> > {get,_,_,_} -> io:format("im
> > innnnnnn~n");%gen_tcp:send(Socket,erl_api:search());
> > _Else -> io:format("im in none ~n")
> > end,
> > io:format("recieve Data from socket:~p~n",[D]),
> > do_echo(Socket);
> > {error, closed} ->
> > ok
> > end.
>
> Another option. Skip the binary_to_list and do pattern matching like this:
>
> ...
>
> <<"{","g","e","t",_/binary>> -> io:format("im
> innnnnnn~n");%gen_tcp:send(Socket,erl_api:search());
>
> ...
>
> -wes
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110407/b6c59b24/attachment.htm>
More information about the erlang-questions
mailing list