Hi Steve,
Many thanks for your reply. It worked by the approach that I put lpeg.so in the same directory with Lua, then start lua with lpeg load:
bin: lua -llpeg
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
>
After that, I tested example from LPeg reference book, and the result showed lpeg load work well.
bin: lua -llpeg
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> -- matches a numeral and captures its value
> number = lpeg.R"09"^1 / tonumber
>
> -- matches a list of numbers, captures their values
> list = number * ("," * number)^0
>
> -- auxiliary function to add two numbers
> function add (acc, newvalue) return acc + newvalue end
>
> -- folds the list of numbers adding them
> sum = lpeg.Cf(list, add)
>
> -- example of use
> print(sum:match("10,30,43")) --> 83
83
>
But, when I tried to test test.lua scripts coming from lpeg-0.9, I got trouble below:
> local m = require"lpeg"
> any = m.P(1)
stdin:1: attempt to index global 'm' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: ?
>
It looks like the statement require"lpeg" does not return correct module address. If trying statement local m = lpeg, the result is the same
> local m = lpeg
> any = m.P(1)
stdin:1: attempt to index global 'm' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: ?
>
The all above were the first issue.
Another issue was regarding LUA_CPATH.
Due to account privilege limitation on Solaris server machine, I was not able to install lua under /usr/local/bin or /usr/local/lib. So the form /home/my_account/bin, /home/my_account/include, /home/my_account/lib, etc was chosen, then added /home/my_account/bin to PATH so that I was able to run lua anywhere. I hope "/home/my_account/lib/lua/5.1/?.so" could be appended to LUA_CPATH, any extend .so file were moved into "/home/my_account/lib/lua/5.1/?.so", obviously I could load lpeg by require"lpeg" conveniently. I ever tried adding "/home/my_account/lib/lua/5.1/?.so" to LUA_CPATH, however, which did not work like I imaged. Could you give me a solution of this issue?
thanks a lot.