erlang initial experiences

Scott Lystig Fritchie scott@REDACTED
Thu Apr 20 06:10:05 CEST 2000


>>>>> "jh" == James Hague <jhague@REDACTED> writes:

>> 3. Support for parsing of command line arguments passed from the
>> UNIX shell seems limited. No getopt() (or did I miss it?), and
>> numbers are passed in as atoms so must go through the dual
>> conversion of atom_to_list and list_to_integer.

jh> Erlang hasn't been much of a Perl-like scripting language thus
jh> far, so I'm not suprised by this.

See the documentation for the init module (in the kernel docs).
Here's a snippet to get an integer value off the command line,
returning 'false' if it isn't there:

        get_command_line_int(Atom) ->
            case init:get_argument(Atom) of
                {ok, [[Value]]} ->
                    list_to_integer(Value);
                _ ->
                    false
            end.

... where the command line argument looks like "-whatever 4", and
'whatever' is arg passed to get_command_line_int/1.

-Scott



More information about the erlang-questions mailing list