generated file names

Ulf Wiger <>
Wed Apr 17 12:23:59 CEST 2002


On Wed, 17 Apr 2002, Laszlo Varga wrote:


>For example
>	erlang:ref_to_list(make_ref()).

>It is unique enough, but not really 'cryptic' again, and
>moreover ref_to_list is something condemned dirty.

Well, the following should be more unique than the above, and not
use any constructs that are officially frowned upon:

unique_name() ->
  {Ms,S,Us} = erlang:now(),
  lists:append([integer_to_list(Ms), ".",
                integer_to_list(S),  ".",
                integer_to_list(Us)]).


If you want it more cryptic, you can call
erlang:md5(list_to_binary(unique_name()), which will make it less
unique, but not by much.

But to make it a valid filename, you'd have to do encode it as
(ascii) hex representation or something.  (:

/Uffe




More information about the erlang-questions mailing list