Previous section To contents Next section

9.9 A simple example

Here is a simple example of how to use the Stdio-functions.

string grep(string indata, string needle)
{
    object out=Stdio.File(),in=Stdio.File();
    object process=
     Process.create_process(({"/bin/grep",needle}),
        (["stdin":out->pipe(),
        "stdout":in->pipe()]) );
    out->write(indata);
    out->close();
    process->wait();
    return in->read();
}
This function filters the indata through the UNIX-command /bin/grep and return the result.


Previous section To contents Next section