File: consult without file part
I am writing an script that needs normal propolis as its input:
script "[{error_string, \" This is broken \ "}]"
all I want to do now is parse arbitrary strings in real proplies, usually I write this to a file and then continue to use the file: consult the file to get the values - this is however a bit like top - so my question in how can I do the same, that is, parse the input string into proplist without sending the data to a file?
source to share
The easiest way to do this is to use erl_eval
as in Odobenus Rosmarus answer , even if it seems a little tricky. Just remember to put it .
at the end of your expression. You can read a little about this topic on the Erlang Central Wiki .
But if you are creating an escript to populate your application with parameters, I would look at a full size argument parser. I've used https://github.com/jcomellas/getopt before . The project is stable, with reasonably good documentation, and does what it needs to do. It requires little configuration, but the generated code remains readable.
source to share