Reputation: 2298
I'd like to execute Perl code efficiently from Java. The purpose of the Perl is mainly to perform regular expression matching (in some tests it Perl was more efficient than Java to do that)
Thus far I've found the possibility of using this: http://metacpan.org/pod/Inline::Java::PerlInterpreter
Another option would be to use Runtime.exec() in java to call Perl.
What is the most performant solution? Does one have an advantage over the other? I can't really see any, except that the PerlInterpreter is still experimental and I don't know if that's going to change. Do you know of any other options to call Perl from Java?
Upvotes: 1
Views: 268
Reputation: 7232
It would have to be a very special case indeed where executing Perl from Java to process a regular expression yields better performance. Regardless of whether Perl can process individual regular expressions faster than Java or not, there is an overhead to starting Perl up from Java, as well as a Thread overhead in Java to correctly manage a forked process.
Most likely, you will get better performance by processing your regular expressions directly in Java, unless you have very large data to query against which may serve to mitigate the startup costs of invoking a separate process.
Recommended steps:
Upvotes: 5
Reputation: 24124
Why are you not happy with java.util.regex.Pattern
and java.util.regex.Matcher
classes that you want to use Perl's regex capabilities? ;-)
Upvotes: 7