cavac has asked for the wisdom of the Perl Monks concerning the following question:
// 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
This still needs a lot of work though, but i see a (very dim) light at the end of the (very long) tunnel.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;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Embedded scripting sandbox? Lua?
by afoken (Chancellor) on Oct 03, 2011 at 18:52 UTC | |
by cavac (Prior) on Oct 04, 2011 at 05:45 UTC | |
Re: Embedded scripting sandbox? Lua?
by perlfan (Parson) on Oct 03, 2011 at 20:04 UTC | |
by cavac (Prior) on Oct 04, 2011 at 05:36 UTC | |
by perlfan (Parson) on Oct 04, 2011 at 13:28 UTC | |
by cavac (Prior) on Oct 10, 2011 at 17:29 UTC | |
Re: Embedded scripting sandbox? Lua?
by Anonymous Monk on Oct 04, 2011 at 06:43 UTC | |
by cavac (Prior) on Oct 04, 2011 at 08:00 UTC | |
by Anonymous Monk on Oct 04, 2011 at 09:26 UTC | |
by cavac (Prior) on Oct 10, 2011 at 17:08 UTC |