I'm trying to get a minimal example of the use of Inline::Lua to work. I've written a small PGLua.pm module, added it and Inline::Lua to the list of safe modules, and tried two different ways of calling Lua code. Neither works.
package PGLua;The above PGLua.pm produces the following error in the Apache log.
use Inline 'Lua' => <<LUA
function lplus( x, y )
return x + y
end
LUA
sub luaPlus{
my $self = shift;
my ( $x, $y ) = @_;
return lplus( $x, $y );
}
1;
[Sat Aug 22 13:06:34.570020 2015] [perl:warn] [pid 31950] [client 127.0.0.1:44738] [/webwork2/NewGenEd/Undefined_Set/1/] Failed to evaluate module PGLua: syntax error at /home/dabrowsa/webwork/pg/lib/PGLua.pm line 11, near "sub luaPlus"\nsyntax error at /home/dabrowsa/webwork/pg/lib/PGLua.pm line 15, near "}"\nCompilation failed in require at (eval 882) line 1., referer: http://127.0.0.1/webwork2/NewGenEd/instructor/setmaker/
Whereas the following produces no error in the Apache log, but apparently the Lua code at the bottom remained unread because when I try to use PGLua::luaPlus in the context of a webwork problem it produces the WW error
"##Undefined subroutine &PGLua::lplus called at [PG]/lib/PGLua.pm line 10."
(Full error message below.)package PGLua;
use Inline 'Lua';
sub luaPlus{
my $self = shift;
my ( $x, $y ) = @_;
return lplus( $x, $y );
}
1;
__END__
__Lua__
function lplus( x, y )
return x + y
end
Warning messages
ERROR in old_safe_ev, PGbasicmacros.pl: <PRE>
## There is an error occuring inside evaluation brackets \{ ...code... \}
## somewhere in an EV2 or EV3 or BEGIN_TEXT block.
## Code evaluated:
## Data::Dumper::Dumper
PGLua::luaPlus( 2, 3 )
##Undefined subroutine &PGLua::lplus called at [PG]/lib/PGLua.pm line 10.
##</PRE><BR/>
at line 1671 of [PG]/macros/PGbasicmacros.pl
Should I give this up as hopeless, or are there more things to try?