views:

1589

answers:

3

Is there a tool available which will convert source code in Perl to source code in C? Any platform is fine.

+6  A: 

The answer is going to be pretty much "No". Perl is an extremely dynamic language. C is a language for statically-sized data types. Any translation of Perl to C will likely be pretty much "execute this subroutine call to simulate what Perl does" repeatedly. And there's little point in building such a translator, as it is unlikely to execute Perl much faster than Perl does.

Ira Baxter
Well, Perl has fixed data types, just not that many of them. The problem is that Perl is dynamic. It may compile differently depending on any number of factors, and that may change how the compiler acts for upcoming source code.
brian d foy
+9  A: 

There is perlcc which "translates" Perl to C.

It's not really a Perl to C compiler; its output is simply a bundle of the Perl interpreter and the parsed bytecode of your program.

ephemient
perlcc and corresponding B:: modules are maintained separately on CPAN by Reini Urban.
Alexandr Ciornii
+16  A: 

The canonical answer to this is MJD's "Why Not Translate Perl to C?".

Sinan Ünür
+1, enjoy your gold Perl expert badge. :)
Adam Bellaire