1

I was wondering is there is any way to interact with Perl 5 code automatically, without creating explicit APIs and publishing it over some protocol. I don't want to limit this question to any specific ways of achieving that - I'm looking for any ideas.

Ruby can be accessed from JVM-based languages via JRuby for example; natively compiled languages are usually accessible via native shared libs / standard calling convention for that platform; others can have the interface autogenerated from code... What are the options for Perl?

4
  • @Virator: I’m not at all sure what that means. Your first paragraph doesn’t map into any known slots in my brain, and the second is nearly as mysterious. Are you talking about XS stuff or what? Commented Nov 25, 2010 at 0:44
  • @tchrist: I want to access some legacy Perl code (that I don't really want to touch) from some other language. Hopefully phasing out the Perl part over time. I'm looking for ways to do that. Commented Nov 25, 2010 at 1:03
  • 1
    honestly, taking legacy Perl code and turning it into an API by writing some minor wrapper around it (from plain old pipe data passing to some socket communication to ...) sounds to me LOTS easier than trying to merge Perl and non-Perl code on native level. YMMV :) Commented Nov 25, 2010 at 2:25
  • @DVK: It's definitely an option. I'll just have to test both ways and see what's easier to use (and what requires less perl rewrites). Commented Nov 25, 2010 at 2:31

2 Answers 2

4

As one option, you can embed a Perl interpreter, as shown here or here or here

Sign up to request clarification or add additional context in comments.

1 Comment

Following that idea, I found pyperl too search.cpan.org/~gaas/pyperl-1.0/perlmodule.pod - easy embedding of perl in python.
4

There is library for embedding Perl into your program (see perlembed.pod) that is compiled automatically - any language can use it, pyperl for Python, PEAR "Perl" extension for PHP, several attempts on using Perl 5 from Perl 6, several attempts to run Perl from JVM (all not finished), Perl.NET.

Also you can go other way, embed program in other language in Perl and just call Perl subs from program in other language. Main Perl program would consist just of calling your program in other language. There is big number of CPAN modules that integrate other languages.

2 Comments

I can see a lot of projects like that, but it's sometimes hard to see which ones are "proof of concept" type and which are serious projects published because they're actually used somewhere and maintained (which is what I'm looking for :) )
perlembed.pod is the very first link in my answer, FYI :) (you answer provides pretty good detail so i'm glad you gave it, though)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.