December 2015 Archives

Perl5 to Java compiler - using a Perl module from Java

Perlito5 now supports calling Perl subroutines from Java.

For example, a Perl module was compiled to "", and it can be called using:

 class TestPerl {
    public static void main(String[] args) throws Exception {
        // initialize the Perl module - setup global variables
        // and create the subroutine entries
        // locate the subroutine main::test
        // and call it with an argument list
        // that is: @res = main::test(123)
        PlObject[] res = Main.apply("main::test", new String[]{ "123" });
        // do something with the results
        for (PlObject s: res) {
            System.out.println("Java result: " + s.toString());

About Flávio S. Glock

user-pic I blog about Perl.