jspl - JavaScript interpreter with perl powers
An example say more than a thousands words:
#!/usr/bin/jspl // Load some modules require('Gtk2', 'Gtk2'); install('Gtk2.Window', 'Gtk2::Window'); install('Gtk2.Button', 'Gtk2::Button'); Gtk2.init(); var window = new Gtk2.Window('toplevel'); var button = new Gtk2.Button('Quit'); button.signal_connect('clicked', function() { Gtk2.main_quit() }); window.add(button); window.show_all(); Gtk2.main(); say('Thats all folks!');
This provides a SpiderMonkey based javascript shell extended by perl, thanks to JSPL perl module.
$jspl [--shell] [--help] [<file>]
jspl can be used either in interactive or script execution modes. The script to be executed can be passed on the command line as file above or jspl can be used in the she-bang line of your script.
#!/usr/bin/jspl <Lot of javascript code>
You can use any of the following
Start an interactive JS shell
Print usage help
Optional. Run a script from the given file.
If not file given, its starts in interactive mode.
Your script should be written in javascript syntax and has available all features of the SpiderMonkey engine, see https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference
Also jspl provides all the services documented in JSPL::Runtime::Stock plus the following:
Array of arguments passed to your script on the command line. Available only in non interactive mode.
This array is an alias to perl's @ARGV.
Exit from the interactive shell
String with the name of the file running, available only in non interactive mode.
This is a string describing the shell version. It has the form "JSPL version <version>".
Salvador Ortiz <sortiz@cpan.org>
Copyright (c) 2008 - 2010, Salvador Ortiz <sortiz@cpan.org>
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING. THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
To install JSPL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JSPL
CPAN shell
perl -MCPAN -e shell install JSPL
For more information on module installation, please visit the detailed CPAN module installation guide.