Perl5 as a first-class script engine in Java

Perlito5 is an implementation of the Perl5 language that runs in the Java / JVM platform.

Perl scripts can now be run from inside Java applications using the standard javax.script API:

// $ javac -cp .:perlito5.jar Script.java
// $ java -cp .:perlito5.jar Script

import javax.script.*;

public class Script {
    public static void main(String[] args) throws Exception {

        ScriptEngineManager factory = new ScriptEngineManager();
        ScriptEngine engine = factory.getEngineByName("Perl5");

        Object o = engine.eval(" $x = 456; say 123 + $x; \"value was $x\" ");
        System.out.println("result: " + o);
    }
}

Perl modules can be loaded after setting @INC.

About 40 core modules have been ported to this distribution, and it passes about 23,000 tests.

Leave a comment

About Flávio S. Glock

user-pic I blog about Perl.