[erlang-questions] Run external program with arguments

Bob Ippolito bob@REDACTED
Wed Nov 14 17:51:54 CET 2007


On 11/14/07, Torbjorn Tornkvist <tobbe@REDACTED> wrote:
> Bob Ippolito wrote:
> > The easiest way is to perform shell quoting over the command you
> > want... take a look at mochiweb_util:cmd_port/2.
> >
> > http://mochiweb.googlecode.com/svn/trunk/src/mochiweb_util.erl
>
> Hm...that join function. Couldn't it be written like:
>
> %%-----------------------------------------------------------------------------
> %% @spec implode(Str::string(), Sep::string()) -> string()
> %%
> %% @doc  split text at first occurence of Char (Char is not include in
> Before
> %%       or After parts)
> %%
> %%  Example:  implode(["a","b","c"], ".") => "a.b.c"
> %%
> %%
> @end------------------------------------------------------------------------
> implode(Data, Seperator) when is_list(Data) andalso is_list(Seperator) ->
>     lists:foldr(fun(X,[]) -> X; (X,Acc) -> X++Seperator++Acc end, "", Data).
>

Probably, but what's there works and it's not a bottleneck in anything we do.

-bob



More information about the erlang-questions mailing list