Kashratul has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

Not much idea about this -> is it possible to write perl code with in java script?

Like embedding perl with in Java.

Thanks

Replies are listed 'Best First'.
Re: writing perl in java script
by holli (Abbot) on Mar 26, 2008 at 08:00 UTC
    Your question is very unclear, but i think I'll just throw in my 2cents, in hope to get a random hit.

    In order to run Perl from within a Browser, you can use the PerlScript Extension. However this will only work under Windows and when you install ActivePerl.

    To embed Perl in Java, there is the javax.script - class which lets you embed script languages in your Javascript application and exposes the apps object model to the scripts it runs. The list of supported languages includes Perl.


    holli, /regexed monk/
      javax.script
      Opening the ressource you provided, I see
      To see the full list of languages, and download the "script engines" - the interfaces fom Java to each of the languages - visit http://scripting.dev.java.net.

      Following that link I indeed see a table of lots of "script" languages supported.

      But no mention of Perl, other than acknowledgement of inspiration for some of the languages features, or the language as a whole.

      Did I miss the right turn somewhere?

      Thanks for the reply. The link "javax.script" was really helpful.

      But I want to get some more info. about this.

      I have gone thru Java Cookbook but I could not find any help there (though by seeing the link I felt that I will get).

      Can u pls guide me where I can get more info about this

      Regards Kashratul

      Thanks for the reply. The link "javax.script" was really helpful.

      But I want to get some more info. about this.

      Can u pls guide me where I can get more info about this

      Regards Kashratul

        Kashratul:

        Hey! You might want to check out this cool new site that excels at helping you answer questions like this. You might want to give it a try!

        ...roboticus
      Hi Holli,

      I went thru Javax.scritp.

      As per the doc given they still don't support perl, like they do for python or Ruby.

      https://scripting.dev.java.net/

      Any work around possible.

      thanks

Re: writing perl in java script
by Corion (Patriarch) on Mar 26, 2008 at 06:57 UTC

    You can use HTTP (under the new and fancy word "Ajax") as an RPC mechanism, much like you can have RPC mechanisms between Java and Perl, and you can use some fancy dispatch scheme to call Perl code from JS code and JS code from Perl code.

    Whether that constitutes "embedding", I don't know. You will still need a JavaScript interpreter and a Perl interpreter for your program.

      Thanks for the reply.
Re: writing perl in java script
by blazar (Canon) on Mar 26, 2008 at 19:49 UTC

    Not much idea about this -> is it possible to write perl code with in java script?

    Like embedding perl with in Java.

    I personally believe that as most other people who replied also pointed out, your question is very poorly phrased. In particular, one point no one has addressed thus far is that JavaScript and Java -despite their respective names- are two largely different languages, and it is not really clear to which of them you're referring to, nor what you really want to do.

    --
    If you can't understand the incipit, then please check the IPB Campaign.
      I think the question is simply : I would like to call a cgi perl script from a javascript code embedded in a html page.