[erlang-questions] binary strings and interspersing erlang variables

Wes James comptekki@REDACTED
Sat Mar 10 00:05:16 CET 2012


Ok, I'll try that.  I'm testing cowboy and trying to put some
variables in the binary string.

Thanks,

Wes

ps.  I just tried it and it worked.  Thanks!

On Fri, Mar 9, 2012 at 3:57 PM, Lukas Larsson
<lukas@REDACTED> wrote:
> You might want to consider creating a iolist, i.e.
> [<<"html">>,Port,<<"</html>">>].
>
> Most if not all output interfaces allow you to mix lists and binaries
> like this. This makes it more elegant to generate complex structures
> (imo) and possibly faster as well as you do not combine the binaries
> until just before sending it over the socket.
>
> Lukas
>
> On Fri, Mar 9, 2012 at 11:37 PM, Wes James <comptekki@REDACTED> wrote:
>> I'm working with binary data like this:
>>
>> <<"<html>
>> <head>
>> <script>
>> </script>
>> </head>
>> <body>
>> </body>
>> </html>">>
>>
>> I then set
>>
>> Port= <<"8080">>;
>>
>> and now to put Port in to the html code above:
>>
>> <<<<"<html>
>> <head>
>> <script>
>> port='">>/binary,
>> Port/binary,
>> <<"';
>> </script>
>> </head>
>> <body>
>> </body>
>> </html>">>/binary>>
>>
>> Is there a better way to do this?
>>
>> Thanks,
>>
>> Wes
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list