perl-parser? or a perl 2 java converter?

G

Guest

Hello!

i have prototyped some applications in perl, and now want to rewrite
them in java...

rewriting from scratch would be quite some work, thus i am looking if
there are some ready means to convert the perl code (as far as possible)
into java code...

google idn't manage to find me anything on this....

alternatively, is there a way to instruct the perl parser to issue the
parsed perl-tree before execution?

or if even this isn't possible, the reflection possibilities in perl
seem a bit limited, is there a way to ask a an instance of an object the
list of implemented methods, and possibly only the methods overwritten
in the current class?
 
B

Ben Morrow

Quoth (e-mail address removed):
i have prototyped some applications in perl, and now want to rewrite
them in java...

rewriting from scratch would be quite some work, thus i am looking if
there are some ready means to convert the perl code (as far as possible)
into java code...

AFAIK there aren't any. Perl->* convertors are provided by the O and
B::* modules, but the ones such as B::C and B::CC that actually produce
working programs in other languages have pretty much all been put on
hold, and it's not recommended you use them any more as they were never
properly finished.

You could always write one, of course :)
alternatively, is there a way to instruct the perl parser to issue the
parsed perl-tree before execution?

You could try B::Concise, but I really don't know what you think you
might do with the information.
or if even this isn't possible, the reflection possibilities in perl
seem a bit limited,

<standard answer for any advanced OO in perl5>
Yes, they are; this will be fixed (with a vengeance) in perl6, but don't
hold your breath.
is there a way to ask a an instance of an object the
list of implemented methods, and possibly only the methods overwritten
in the current class?

Not in general. You could walk the namespace and get all the defined
subs with something like

no strict 'refs';
$\ = "\n";
my $class = 'My::Class';
for my $i (keys %{"$class\::"}) {
print $i if exists &{"$class\::$i"};
}

but this

1. won't distingish methods from functions

2. won't distinguish public/private methods (the concept doesn't exist
in Perl)

3. won't find inherited methods (though you could check @ISA and
recursively walk those classes as well)

4. most importantly, won't find AUTOLOADed methods unless they've been
stubbed, which is usual for AUTOLOADed functions but not for methods as
you don't need to.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top