在Erlang中,
我们可以通过命令行参数将多个输入传递给Erlang系统。
erl -sname name1 -setcookie abcd
如何为单个标志传递多个值?
答案 0 :(得分:1)
我们可以将多个值发送到单个标志。
值由空格字符
区分erl -key1 val1 val2 val3
Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false]
Eshell V6.3 (abort with ^G)
1> init:get_argument(key1).
{ok,[["val1","val2","val3"]]}
您可以传递多个键值对,例如
erl -key1 val1 val2 val3 -key2 val11 val12 val13
Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false]
Eshell V6.3 (abort with ^G)
1> init:get_argument(key2).
{ok,[["val11","val12","val13"]]}
2> init:get_argument(key1).
{ok,[["val1","val2","val3"]]}
如果您多次传递密钥,则会得到类似的值
erl -key1 val1 val2 val3 -key1 val11 val12 val13
Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false]
Eshell V6.3 (abort with ^G)
1> init:get_argument(key1).
{ok,[["val1","val2","val3"],["val11","val12","val13"]]}
2>
答案 1 :(得分:0)
您可以在Erlang文档here中了解有关处理命令行参数的更多信息。