Perlito Archives

Perl5 to Java compiler - integrating with Rhino

I'm experimenting with calling Java libraries from Perlito5-Java; calling into the JVM Javascript engine was pretty easy:

# here we import the Java packages into Perl packages:
package ScriptEngineManager {
    import => "javax.script.ScriptEngineManager"
package ScriptEngine {
    import => "javax.script.ScriptEngine"

# these are Perl variables, but they are also Java objects
# so we have to declare which package they belong to:
my ScriptEngineManager $manager = new ScriptEngineManager();
my ScriptEngine $engine = $manager->getEngineByName("JavaScript");

# now we can call the Rhino javascript engine:
    'print( "JS thinks that the result is " + ( 1+1 ) + "\n" );'

# JS thinks that the result is 2

The source code is at; I've tested with javac 1.7.0_79 in Ubuntu.

Perl5 to Java compiler - 2nd hackathon

We've had another hackathon at work. This time Bosko, Bruno, Frederico, Yati, and I hacked on the Perlito Perl5-to-Java compiler.

We started adding unit tests - so that we can automatically extract a list of implemented features; the existing Perl tests are not properly organized "by feature".

The latest additions to the Java backend are:

Perlito - reviewing some older code

Today I've finally updated the Perlito compiler ChangeLog, this covers a little more than a year of commits.

The most significant update was the new Perlito5-to-Java backend, which is work-in-progress. It covers a lot of ground, but there is a lot more.

There were also some interesting new Perlito5-to-Javascript features, such as regex /e modifier, and file operators support in nodejs.

The Perl6 backends have not been updated, but things still work.

While reviewing the README-perlito6 file, I've found some interesting stuff that I haven't touched in a while - here is a piece of generated code that goes through 3 different languages:

Perl5 to Java compiler is 1 month old, and we have a hackathon

We are having a hackathon at work, and Bosko, John and I have hacked together a working Perl script that executes in a Java environment (HBase).

a perl5 to Java compiler - first benchmark

I've written a small performance test. And it is not bad!

First perl:

$ time perl misc/Java/
done 64000000

real    0m3.964s
user    0m3.963s
sys     0m0.004s

And then Perl-in-Java:

$ touch Test.class ; rm Test.class ; perl -Isrc5/lib -I. -It -Cjava misc/Java/ > ; javac ; time java Test
done 64000000

real    0m0.840s
user    0m0.584s
sys     0m0.302s

a perl5 to Java compiler - week 3

The compiler now has a small test suite. The main additions in the last 10 days were implementing global variables, better support for references, data structures, string interpolation, and a few new subroutines in the CORE namespace and operators.

a perl5 to perl6 translator

The "perlito" perl5 to perl6 compiler is online at:

It is also available as an irc bot for snippets and as a command line script.

formats added to perlito5

perlito5 is a Perl compiler written in Perl.

The format statement was required in the grammar for completeness. The 'format' command is not supported at the emitter side - it compiles, but it doesn't run yet.

Some other features are still marked as TODO and are simple to implement:

- dot-decimal strings (without the 'v'),
- "'" meaning "::",
- using 'CORE::' in odd places - 'CORE::if' in place of 'if' and 'CORE::and' in place of 'and'.

With these in place, the grammar will be "100% complete" - the tests will eventually tell if we got there or not.…

indirect-object added to perlito5

perlito5 is a Perl compiler written in Perl.

The tests* for indirect-object and bareword disambiguation can be run online at (you need to copy-paste the tests, it is not automated).

* t5/01-perlito/27-syntax-indirect-object.t

tie() in perlito5

I've just added a small tie() example to the perlito5-in-the-browser page.

This was implemented today, and it only supports a few methods for now.

tie() does not make perlito5 any slower - the tied containers use a separate class, while the non-tied perl5 containers are javascript native array and hash objects.

About Flávio S. Glock

user-pic I blog about Perl.