[erlang-questions] two simple escript questions

Joe Armstrong <>
Fri Jul 2 23:05:10 CEST 2010


#!/usr/local/bin/escript
main(_) ->
    Name = io:get_line("What's your name?\n> "),
    io:format("Hello ~s!~n", [Name]).

erl -man io

is your friend

/Joe



On Tue, Jun 29, 2010 at 9:44 PM, Gonzalo <> wrote:
> Hi all,
>
> I have two questions regarding the following simple erlang script:
>
>
> #!/opt/local/bin/escript
> main(_) -> {ok, Name} = io:read("What's your name?\n> "),
>           io:format("Hello ~s!~n", [Name]).
>
> Execution:
>
> Denver:Erlang gonzalo$ ./hello
> What's your name?
>> gonzalo.
> Hello gonzalo!
>
> It works for a simple atom.
>
> 1. I would like to modify this script so I could type anything.
> Examples: gonzalo, jean paul, Gonzalo, Jean Paul, etc.
>
> 2. It seems that io:read() expects an expression ending with a dot (.)
> Is it possible to avoid this? Just pressing enter should work.
>
> Thanks for your tips.
> Gonzalo.
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
>
>


More information about the erlang-questions mailing list