[erlang-questions] binary strings and interspersing erlang variables

Erik Søe Sørensen eriksoe@REDACTED
Sat Mar 10 10:08:01 CET 2012


For completeness, I'll provide an answer which is closer to the original -
and constructs a binary:
The strings need not be marked as binaries; you can just put the string
literals directly inside a binary constructor:

<<"<html>
<head>
<script>
port='",

Port/binary,
"';
</script>
</head>
<body>
</body>
</html>">>

Den 9. mar. 2012 23.37 skrev Wes James <comptekki@REDACTED>:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120310/77f2e18d/attachment.htm>


More information about the erlang-questions mailing list