[erlang-questions] I have a creepy feeling

Alex Shneyderman <>
Thu Nov 17 07:13:59 CET 2011


ouch,
yes the ordering was my problem. Because the others I tried to no
effect, but of course sine the ordering is my problem.
Thanks for your help,Alex.

On Thu, Nov 17, 2011 at 7:09 AM, Rick Pettit <> wrote:
>
> On Nov 16, 2011, at 11:52 PM, Alex Shneyderman wrote:
>
>> That I am not able to send mails to this mailing list. I sent about 4
>> questions in total since the start of my membership and have never
>> received a response. While my previous questions might have been a bit
>> idiotic and at the end I did not miss the answer the last one is a bit
>> of a mystery to me and I really hope that there is simply something
>> wrong with my subscription.
>>
>> Here is the question I asked:
>>
>> Does anyone know why this script does not go away after an empty line entry?
>>
>> #!/usr/bin/env escript
>>
>> main(_Args) ->
>>  Result = io:get_line(">"),
>>  read_more( Result ).
>>
>> read_more(Line) ->
>>  io:format("~p~n",[Line]),
>>  Result = io:get_line(">"),
>>  read_more( Result );
>> read_more("~n") ->
>>  ok.
>
> I think you have 2 problems there:
>
>  1) you need to reorder your clauses in read_more/1 -- that first clause will always match
>
>  2) you need to replace "~n" with either "\n" or [$\n]
>
> This version works:
>
> #!/usr/bin/env escript
>
> main(_Args) ->
>  Result = io:get_line(">"),
>  read_more( Result ).
>
> read_more("\n") ->
>  ok;
> read_more(Line) ->
>  io:format("~p~n",[Line]),
>  Result = io:get_line(">"),
>  read_more( Result ).
>
> So does this version:
>
> #!/usr/bin/env escript
>
> main(_Args) ->
>  Result = io:get_line(">"),
>  read_more( Result ).
>
> read_more([$\n]) ->
>  ok;
> read_more(Line) ->
>  io:format("~p~n",[Line]),
>  Result = io:get_line(">"),
>  read_more( Result ).
>
> -Rick
>
>



More information about the erlang-questions mailing list