How to convert OO Perl to Java?

I inherited a large monolithic body of OO Perl code that needs to be gradually converted to Java (at the request of the client). I know both languages, but I'm rusty on my Perl skills. Are there any tools (Eclipse plugins?) That you people can recommend for pain relief?

+3
source share
3 answers

Does the OO code use Moose? If so, you can automatically convert class declarations using introspection.

To gradually convert Perl to Java, you can include Java code in a Perl program with Inline :: Java .

Perl JVM, , Perl Java?

+8

PLEAC - .

+1

inccode.com Perl- Java-. perl- - perl. perl , .

VarBox : ref (HASH), ref (ARRAY) BoxModule Perl-.

show perl script, "hello world". LibConsole script 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 , , "" . , , , (module = "{class}" ) .

, .

     public class hello extends CRoutineProcess implements IInProcess
 {
   VarBox call ()
   {
      hello_on_console("hello world");
      return hello_on_printer("hello world");

   }
   BoxModule<LibConsole> get_console ()
   {
      BoxModule<LibConsole> varConsole = new BoxModule<LibConsole>(LibConsole.apply());
      return varConsole;
   }
   BoxModule<test.LibPrinter> get_printer ()
   {  
      BoxModule<LibPrinter> varPrinter = new BoxModule<LibPrinter>(get_console().getModule().get_printer());
      return varPrinter;
   }
   VarBox hello_on_console (VarBox varHello)
   {
      BoxModule<LibConsole> varConsole = new BoxModule<LibConsole>(get_console());
      return varConsole.getModule().output(varHello);
   }
   VarBox hello_on_printer (VarBox varHello)
   { 
      BoxModule<LibPrinter> varPrinter = new BoxModule<LibPrinter>(get_printer());
      return varPrinter.getModule().output(varHello);
   }

 }

.

+1
source

Source: https://habr.com/ru/post/1712245/


All Articles