![]() |
|
Do you know where your variables are? | |
PerlMonks |
Re^2: Run Perl 5 in the Browser!by haukex (Archbishop) |
on Oct 06, 2018 at 10:33 UTC ( [id://1223619]=note: print w/replies, xml ) | Need Help?? |
Are you exposing an API or you have a DSL? In Perl scripts running inside WebPerl, I expose all of JavaScript to Perl, in two ways:
So this way, you can do everything in Perl, and use normal Perl operations to manipulate Perl objects, which actually runs JavaScript in the background. The interface is documented here. The gory guts can be found in WebPerl.pm and WebPerl.xs (with some supporting code, such as Perl.glue() and Perl.dispatch(), in webperl.js). (You'll see that currently, a lot is done with copying strings back and forth between JS and Perl, and with both JS's and Perl's eval, which in some places could probably be optimized in a future version.) How can you a access the Dom with Perl? Since you can use all of JavaScript, you can use native JS (like the example LanX showed), or any JavaScript library of your choice, such as jQuery. I show examples of both in the source webperl_demo.html (don't mind the currently screwy syntax highlighting on GitHub that's highlighting stuff in dark red). Let me know if you have any further questions! Minor edits to add a few small details.
In Section
Perl News
|
|