It would probably be better to just let everything be done via stdin
and stdout, using pipes:
========
#!/usr/local/bin/lua
file = io.stdin:read("*all");
file = string.gsub(file, "localgreek(%b{})", function(lines)
return "localgreek"..string.gsub(lines, 'a', 'b');
end);
io.stdout:write(file);
=======
You will probably want to have the "return "localgreek" ..." part of
the code just call a function which iterates over your table of
substitutions for each capture. Notice that you need the "localgreek"
part concatenated otherwise you lose it.
HTH,
--
-Patrick Donnelly