ARTICLES

Klacke's examples
Written by Raimo, 29 Apr 2010

The original article and examples was written by Claes Wikstrom in 1998. In april 2008, We removed an example that no longer works and revised the examples to eliminate warnings and use the modern type tests (when is_list(List) instead of when list(List)). In april 2010 we removed the GS example since that GUI library should be deprecated.

In this document I aim to provide a number of small examples of nice Erlang programs. The goal of these examples is to let the reader get started immediataly doing some interesting stuff with the erlang programming environment. The document assumes some knowledge about erlang programming in general.

Programs in this document

For more hardcore like people who just want to see the source code, I provide a list of all Erlang examples described and commented in this document immediataly.

count_chars.erl
Count the number of 'x' chars in a file. Different versions.
wc.erl
A small wc look alike.
find.erl
A small find look alike.
slogger.erl
A simple term logger. There is also a small example.
glogger.erl
The same logger again with the gen_server module.
klib.erl
My personal goodies library.
time_server.erl
A TCP/IP time server.
chargen.erl
A threaded chargen server.
ftpd.erl
A complete ftpd.

We start off with some examples of file handling. Most off the stuff related to file handling resides in the module called file. The easist method of finding out which functions that are available in the file module is to read the manual page. The manual page is available on UNIX systems by invoking the command % erl -man file at the UNIX shell prompt. This of course assumes a correctly installed Erlang system. On a Windows box, there is no manual reader but exactly the same information is available in HTML format.

File IO
Written by Raimo, 29 Apr 2010

Part 1 of Klacke's examples

Socket IO
Written by Raimo, 29 Apr 2010

Part 2 of Klacke's examples

Powered by Erlang Web