Problem: want to read content of a file (size less than 1MB) into a Erlang variable, do some text replacement and write modified contents to a new file. I am new to Erlang and want to use simple code with no error handling (use it from Erlang shell).
I have tried:
File = file:read_file("pbd4e53e0.html").
But when using
string:len(File).
I get
exception error: bad argument in function length/1 called as length({ok,<<">}) in call from string:len/1 (string.erl, line 66).
Next step is to do replacement:
re:replace(File, "<a href=\'pa", "<a href=\'../pa/pa", [{return, list}]).
Question 1: How should I read the file into an Erlang variable?
Question 2: Is the replacement ok?