views:

519

answers:

5

Hi,

I am looking for Perl implementation in Java. Something like Jython is for Python. I found PLJava but it needs both JVM and Perl compiler installed. I need something which does not need a Perl compiler.

I need to run some Perl code in a Java class.

UPDATE: I figured out that PLJAVA is what I need. Does anybody know some tutorial?

UPDATE 2: Has anybody played with the Inline::Java module. UPADTE 3: I also could not install Inline::Java.

A: 

Sleep

vartec
That is Perl like, but not perl
Ilija
+1  A: 

If you are not going to use a Perl compiler, exactly what are you looking for?

What do you mean by a Perl implementation for Java? If you want to embed Perl in your Java programs, you are going to need a Perl compiler.

Yuval A
Hi, I need to run some Perl code inside a Java class. The same as one can do with Python with Jython.
Ilija
What he's saying is that Perl code is dynamic and can do compilation during runtime, so in order to run Perl code you have to have a Perl interpretor.
mpeters
+5  A: 

Jython isn't fully compatible with CPython (or whatever you would rather call the original C++ Python interpreter), but wherever either differs from the language spec is a bug. Unfortunately, Perl 5 is much more complex and lacks any formal language specifications at all -- the language effectively being defined as "what does the perl executable do" -- so there exists no other implementation of the Perl 5 language aside from the Perl 5 interpreter. Unfortunate, but that's history. Perl 6 does have a language spec and multiple (incomplete) implementations, but that's not likely to be useful to you.

PLJava was an attempt to do exactly what you want, call Perl from Java. It does so via JNI (stuffing native code into Java) linking to libperl. However, it's not been updated since 2004 and I don't know how well it works.

Edit

I hadn't seen Inline::Java::PerlInterpreter before -- unfortunately it doesn't seem to work with my system Perl.

ephemient
+1  A: 

It sounds to me like the problem you are having is that you do not have a Perl compiler/interpreter available, yet you need to execute some Perl code. Unfortunately, I don't think that there exists anything like Jython for Perl. The only projects that I know of that can do what you are asking is PLJava and JPL. Unfortunately, it looks like both projects are abandoned.

It would be a cool project though, as I believe there is a need for something like this.

igotmumps
Cool project it may be, I think that for best results all languages should be implemented in C. In particular, something as complicated as Perl, with it's idiomatic quirks and oddities, isn't something that will run will under Java. Two layers of abstraction for Perl is going to be rough at best.
Chris Lutz
+1  A: 

You can use par including modules (or even as an executable) if you don't have perl installed on the target platform: http://search.cpan.org/dist/PAR/lib/PAR.pm