two simple escript questions

Gonzalo <>
Tue Jun 29 21:44:44 CEST 2010


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.


More information about the erlang-questions mailing list