Hi everybody! Im new in Elixir and i foun a problem that maybe someone can help me:
For learning proposes, I’m solving some exercise from Codeabby and I download the data and save it in a file to latter read it from stdin.
The command that Im using to read stdin is IO.read(:stdio, :line) and its working in a program like this:
defmodule Prueba do
def main do
name = IO.read(:stdio, :line)
IO.puts name
end
end
Prueba.main
and in terminal a run this: cat Data.txt | elixir prueba.exs
And it works. The problem is, to summit my solution, a pipeline tries to compile it, but when it sees the line Prueba.main, it starts the program and throws me an error. I Found this because I tray in IEX c(“program.exs”) and have the same error. it will be fixed if I delete Prueba.main, but it would execute when I type in the terminal cat Data.txt | elixir prueba.exs.
My question is… there’s a way to execute the program without the final line? or what do you think about this situation?