!!!Welcome to WebPerl! {{ref_image webperl.png}} 欲しかったやつ!! javascriptをperlで置き換えられる。 https://webperl.zero-g.net/ WebPerl uses the power of WebAssembly and Emscripten to let you run Perl 5 in the browser! WebPerl does not translate your Perl code to JavaScript, instead, it is a port of the perl binary to WebAssembly, so that you have the full power of Perl at your disposal! WebPerlは、WebAssemblyとEmscriptenの機能を使って、Perl 5をブラウザで実行できるようにします。 WebPerlはあなたのPerlコードをJavaScriptに変換するのではなく、WebAssemblyへのperlバイナリのポートですので、自由にPerlの能力をフルに活用できます! →[Run Perl in your browser with WebPerl (Webassembly) - online demo page|https://js.do/perl/] *[demo|http://www21051ue.sakura.ne.jp/webperl/webperl_demo.html] *[demo|http://www21051ue.sakura.ne.jp:5000/webperl_demo.html] *[ブラウザでperlを動かす|http://www21051ue.sakura.ne.jp/a.html] *[じゃんけんぽん|http://www21051ue.sakura.ne.jp/jankenpon.html] [webperl_demo.html]
This is a demo of WebPerl!
!!Perl Advent Calendar 2018 ![Perl in the Browser|http://www.perladvent.org/2018/2018-12-02.html] "Busted Presents!", Tinsle Gumdrop complained. "I hate re-writing code." It was Tinsle's job to port a whole bunch of backend validation logic code from their Perl based internet web app to the JavaScript front end so the validation could run client side too. "I bet those Valentine's cherubs who code in Node don't have this problem", she thought to herself. "At least they can run the same code on the server and in the browser." If only there was a way to run Perl code within the browser also... WebPerl The JavaScript engines in modern web browsers are crazy powerful optimized insanity - even on occasion shipping an entire LLVM compiler to just in time compile the JavaScript code down into native instructions in order to get native performance. In order to help get this level of performance you can use asm.js - a specialist subset of JavaScript to represent low level operations that the JavaScript engine can easily compile down to native code. Or, if your modern browser supports it (like recent versions of Chrome, Firefox, Safari and IE do) you can skip the JavaScript representation entirely and use a machine independent binary format to describe operations the JavaScript engine should run with WebAssembly. It's possible to compile C code using Emscripten to produce JavaScript code or WebAssembly that (when further automatically compiled for JIT performance in the browser) will run at near-native speed. Of course, Tinsel doesn't want to run any C based code in the browser - she wants to run Perl code. What you need to run Perl code is perl - the Perl interpreter - which, as luck would have it, is itself a C based program. So using Enscripten we can compile a version of perl that can be used, with a bunch of shims and bridges, to execute Perl code embedded in our HTML source code. This all sounds like a lot of work - or would be, if Hauke Dämpfling's WebPerl project hadn't done all the hard work for us already. All we need to do to run Perl code is include a single script tag in our HTML linking to a JavaScript file containing the precompiled perl interpreter and suddenly we're able to write Perl code directly in our webpages. [A working example|http://www21051ue.sakura.ne.jp/webperl/fib.html] For fun, let's write some code to generate Fibonacci numbers in our browser...in Perl. fib( ) = Assuming you're reading this article with a recent web browser then this code is entirely runnable directly in the browser. There's a lot to unpack in this dense example: !原文 *At the very top of the script we load the webperl code from the webperl CDN. We don't even have to host this on our own server. *Once we've done that we're able to use a special form of the