[erlang-questions] I need a little newcomer help with basic STDIN\OUT code.
Daniel Goertzen
daniel.goertzen@REDACTED
Thu Sep 11 20:41:33 CEST 2014
The program below will read and then write one line at a time; hopefully it
will help you get started. Keep in mind that the task you describe isn't
going to touch on concurrency or any of the other great parts of Erlang.
Try writing a little proxy server, then you will have fun. :)
#!/usr/bin/env escript
main(_Params) ->
handle().
handle() ->
handle(io:get_line([])).
handle(eof) ->
halt(0);
handle(Data) ->
io:format("~s", [Data]),
handle().
On Thu, Sep 11, 2014 at 11:07 AM, Eliezer Croitoru <eliezer@REDACTED>
wrote:
> Hello,
>
> My name is Eliezer and I have never used erlang before.
> I am writing couple helpers for squid proxy server as a practice task.
> I understood that erlang can provide concurrency options and was curios
> about writing a small acl helper using it.
> I have written example helpers in python, ruby, perl and couple other
> languages and I want to write one in erlang too.
>
> Since I am not familiar with the syntax I would like to get a
> recommendation about a brief tutorial that can help me get this specific
> task done.
> The program task is:
> read each line from STDIN and response accordingly to STDOUT by a
> procedure\function\method.
>
> In ruby, perl and python I have a method to fetch only one line from STDIN
> which allows me to run a couple things on this line only while the STDIN
> buffer receives more content.
>
> I would like to do the same using erlang.
>
> Any help will be appreciated.
>
> Thanks,
> Eliezer
> _______________________________________________
> 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/20140911/ab077ea1/attachment.htm>
More information about the erlang-questions
mailing list