[erlang-questions] reading data from a file

Jayson Vantuyl <>
Thu Dec 3 05:49:03 CET 2009


file:consult/1.  Note that I don't believe it recovers the comments, so rewriting files with it can be ugly unless you want to do something like "All bare strings are preserved as comments".

That said, i've always found file:consult/1 to be worth it's weight in gold, even if it's unusually named.

On Dec 2, 2009, at 8:00 PM, jm wrote:

> I have a file of erlang terms with comments of the form,
> 
> 
> %% comment
> [
> {string(), {atom(), atom() | integer}}
> ].
> 
> For example,
> %% comment
> %% another comment
> [
> {"Some text", {some, none}},
> {"More text", {more, 1}}
> ].
> 
> 
> as I thought this wold be easy to read in as many of the data files used with OTP have similar formats, eg emake files. Now I'm searching for a convenient function to road this in. I seem to be missing something. I've found io:scan_erl_exprs/3 but this seems a little low level. Is there a higher level call which will convert this text into a matching data structure (quick and dirty is fine)? Is there better way to do this that is not quick and dirty, and would be safer for publicly submitted files?
> 
> thanks in advance,
> Jeff.
> 
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org

-- 
Jayson Vantuyl








More information about the erlang-questions mailing list