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

Hi,

We have a few java classes that we would like to convert to Perl, mainly doing calculations and string concatenation.

I wonder if there is an automatic way to do that conversion, since those java classes may require update every now and then. Amit.

Replies are listed 'Best First'.
Re: How to conevrt Java to Perl
by repson (Chaplain) on Feb 02, 2001 at 06:54 UTC
    From fortune:

    : I've heard that there is a shell (bourne or csh) to perl filter, does
    : anyone know of this or where I can get it?
    Yeah, you filter it through Tom Christiansen. :-) -- Larry Wall

    The same applies for java, the only reliable filter is a human.

Re: How to conevrt Java to Perl
by clemburg (Curate) on Feb 02, 2001 at 14:10 UTC

    I have done some of that game with Test::Unit, porting the JUnit framework (Kent Beck and Erich Gamma) to Perl. You can get a good headstart by text-filtering method declarations over into Perl, but after that, you need to get manual.

    A warning: methods dispatching on the type of some basic type argument (e.g., string vs. integer) can be a little problematic.

    Also, you will find that just porting the methods of the classes will lead to very artifical Perl.

    FYI, I wrote Test::Unit::InnerClass to make porting Java to Perl easier. This class emulates the anonymous inner classes syntax feature of Java in Perl. It may help you in your adventures.

    Good Luck!

    Christian Lemburg
    Brainbench MVP for Perl
    http://www.brainbench.com

Re: How to conevrt Java to Perl
by MeowChow (Vicar) on Feb 02, 2001 at 04:23 UTC
    How to convert a Java class to a Perl class in four easy steps:
    • Have your students trade in their copies of _Learn Java and Get Great Abs in 7 Minutes_ for Camel books.
    • Explain what happens when you hold down SHIFT plus a number key.
    • Fire your Java TA and hire just another perl hacker.
    • Have your students post their homework questions here.
    :P

    Originally posted as a Categorized Answer.