[Ilugc] Simple line by line echo in lua

  • From: girishvenkatachalam@xxxxxxxxx (Girish Venkatachalam)
  • Date: Sat, 12 Jan 2013 16:30:10 +0530

This is a really nice program.

$ cat fread

#!/usr/local/bin/lua

while true  do
        local line = io.read()

        if line then -- instead of line ~= nil
                print(line)
        end

        if not line then break end
end


It reads each line and prints it out.

Run it like this:

$ ./fread
<type>
.
.
.
<Ctr-D>

Or

$./fread </etc/passwd

I think you can easily follow the code.

I will take you thro' some of the lua rocks or modules in the following week.

We will first look at the interesting socket module.

And we need to also learn lua's coroutines.

I have understood that.

Certain advanced stuff like metatables, weak tables and so on are the
only remaining
items.

And many lua modules have to be looked at.

I certainly want to consider the postgres, SQLite module and many
other utility modules.

Once we advance to that level then we are ready for the talk.

-Girish
-- 
Gayatri Hitech
http://gayatri-hitech.com

Other related posts:

  • » [Ilugc] Simple line by line echo in lua - Girish Venkatachalam