May 2012 Archives

Implementing Perl6 eval($str, :lang)

Moritz++ helped me implement a proof of concept eval-perl5 that works in rakudo, and uses Perlito5 (a perl5 compiler written in perl5).

This snippet could be used to implement a perl5 compatibility layer that works both in rakudo and niecza (and maybe pugs).

Perlito5 -Cperl6 is invoked using shell(). It compiles the string to perl6, and the result is eval'ed using plain perl6 Str.eval():

multi eval($str, :$lang! where 'perl5') {
my $inp_file = "tmp.p5";
my $out_file = "tmp.p6";
my $fh = open($inp_file,…

About Flávio S. Glock

user-pic I blog about Perl.