[erlang-questions] Erlang term to ASCII
Fri Feb 7 23:18:28 CET 2014
Bob wins the moral victory. Loïc wins the stuffed animal. :-)
On Fri, Feb 7, 2014 at 11:25 AM, Loïc Hoguin <> wrote:
> Str = io_lib:format("~9999999999999999999999999p", [Data])
> On 02/07/2014 07:17 PM, Brandon Clark wrote:
>> I have 2 production systems, one Erlang and one not, both maintaining
>> copies of a large, deeply-nested Erlang data structure. I need to set
>> up a monitoring script to confirm that both systems are holding
>> identical copies of the data structure.
>> The non-Erlang system is holding an ASCII rendering of the data
>> structure. Computing an MD5 sum of this string is easy. If I can get
>> the Erlang system to convert its data structure to a string, I can have
>> it compute an MD5 sum as well and the monitoring is simply a matter of
>> comparing hashes.
>> I'm stuck on the process of converting the Erlang term to a string.
>> Str = io_lib:format("~p", [Data])
>> gives me what I want, except that it includes newlines and indentation
>> that I can't expect the non-Erlang system to have.
>> Str = io_lib:format("~w", [Data])
>> eliminates the newlines and indentation but renders the textual
>> components of Data as lists of integers, guaranteeing the result won't
>> match the non-Erlang system.
>> So the question is, how do I get a "~p"-style rendering of an
>> arbitrarily-large Erlang term /without/ newlines and indentation?
>> Thank you!
>> ~Brandon Clark
>> erlang-questions mailing list
> Loïc Hoguin
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions