// Forward mail to private account on weekend if weekday > 5 then email.reciever = "private@example.com" exit; end if email.subject has "TEST" then email.mailbox = "testmails" else if email.sender == "boss@example.com" email.mailbox = "bigboss" else email.mailbox = "trash" end #### x = 0 for i = 1, #foo do x = x + foo[i] end return x #### use strict; use warnings; use Lua::API; my $L = Lua::API::State->new; my $status = $L->loadfile("test.lua"); if($status) { die "Failed to load file: " . $L->tostring(-1); } $L->newtable; for(my $i = 1; $i <= 5; $i++) { $L->pushnumber($i); $L->pushnumber($i*2); $L->rawset(-3); } $L->setglobal("foo"); my $result = $L->pcall(0, Lua::API::MULTRET, 0); if($result) { die "Failed to execute file: " . $L->tostring(-1); } my $sum = $L->tonumber(-1); print "Script returned $sum\n"; $L->pop(1); $L->close;