如何将OO Perl转换为Java?

我inheritance了OO Perl代码的大型单片体,需要逐步转换为Java(根据客户端请求)。 我知道这两种语言,但我的Perl技能很生疏。 有没有人可以推荐的工具(Eclipse插件?)来缓解疼痛?

OO代码是否使用Moose? 如果是,则可以使用内省自动转换类声明。

要逐步将Perl转换为Java,可以使用Inline :: Java将Java代码包含到Perl程序中。

在JVM项目上有Perl ,也许它可以用于将Perl编译为Java?

我说PLEAC是最好的资源之一。

inccode.com允许您自动将perl代码转换为java代码。 然而,由于perl中的动态类型,perl变量的转换有点棘手。 perl中的标量变量可以包含对任何类型的引用,并且在执行代码时已知实际引用的类型。

Translator使用VarBox类封装所有预定义类型:ref(HASH),ref(ARRAY)和BoxModule,用于封装对Perl模块的引用。

示例显示perl脚本,它调用两个模块来打印“hello world”。 模块LibConsole在脚本中实例化,模块LibPrinter通过调用LibConsole中的方法来访问。

#!/usr/bin/perl use strict; use test::LibPrinter; use test::LibConsole; hello_on_console( "hello world"); hello_on_printer( "hello world"); sub get_console { my $console = test::LibConsole->new(); return $console; } sub get_printer { #@cast(module="test::LibPrinter") my $printer = get_console()->get_printer(); return $printer; } sub hello_on_console { my ($hello) = @_; my $console = get_console(); $console->output ($hello); } sub hello_on_printer { my ($hello) = @_; my $printer= get_printer(); $printer->output ($hello); } 

转换器现在必须是两个模块的类型,而perl没有定义用于声明对象的特定运算符,假设名为“new”的方法返回对模块的引用。 当返回对模块返回引用的方法时,注释cast(module =“{class}”)可用于通知翻译者模块的类型。

由于翻译器控制分配中类型的一致性,因此将传播已识别的变量类型。

  public class hello extends CRoutineProcess implements IInProcess { VarBox call () { hello_on_console("hello world"); return hello_on_printer("hello world"); } BoxModule get_console () { BoxModule varConsole = new BoxModule(LibConsole.apply()); return varConsole; } BoxModule get_printer () { BoxModule varPrinter = new BoxModule(get_console().getModule().get_printer()); return varPrinter; } VarBox hello_on_console (VarBox varHello) { BoxModule varConsole = new BoxModule(get_console()); return varConsole.getModule().output(varHello); } VarBox hello_on_printer (VarBox varHello) { BoxModule varPrinter = new BoxModule(get_printer()); return varPrinter.getModule().output(varHello); } } 

已翻译的代码需要执行运行时库。