Run Perl in the browser with WebPerl!

View the Project on GitHub haukex/webperl

[ Using - Building - 🦋 - Notes - Legal - Wiki ]

WebPerl Experimental Perl 6 Support 🦋

Thanks to Paweł Murias and his amazing work on Rakudo.js and 6Pad, I’ve been able to patch support for Perl 6 into WebPerl!

Currently requires Google Chrome (due to BigInt support), see the Quick Start below on how to get this up and running on your local machine!

<script src="webperl.js"></script>
<script type="text/perl6">

say "Hello, Perl 6 World!";   # goes to JavaScript console by default

my $document = EVAL(:lang<JavaScript>, 'return document');
my $window   = EVAL(:lang<JavaScript>, 'return window');
	.addEventListener("click", -> $event {
		$window.alert("You clicked the button!");
	} );

Quick Start

Have fun!

Experimental Status and Notes


My code steal^H^H^H^H^Hborrows the prepackaged Rakudo.js build from 6Pad and caches it locally. The script experiments/p6/6init.pl also patches the experimental P6 support into webperl.js (see the Quick Start above).

Note that both Perl 5 and Perl 6 are only loaded on demand by webperl.js, so if you only use one or the other, you won’t have the overhead of loading both.

For now, I’ve basically just patched Rakudo.js’s evalP6() into Raku.eval(), and NQP_STDOUT into Raku.output, to make things more like the Perl 5 WebPerl, and provided some of the same API for Perl 6 as I provide for Perl 5.

The JS API provided by WebPerl for Perl 6 currently closely mirrors the Perl 5 API: There is a JS object Raku which provides the following functions / properties that do mostly the same as for Perl 5:

You can add Perl 6 code to your HTML pages with <script> tags with type="text/perl6" or type="text/raku".

For everything else, I defer to Rakudo.js for now! I will update this documentation as things evolve.

Additional notes on WebPerl’s experimental Perl 6 support may be found in the GitHub Wiki.

Copyright (c) 2018 Hauke Daempfling (haukex@zero-g.net) at the Leibniz Institute of Freshwater Ecology and Inland Fisheries (IGB), Berlin, Germany, http://www.igb-berlin.de

Please see the “Legal” page for details.

You can find the source for this page at https://github.com/haukex/webperl/blob/gh-pages/perl6.md