#!/usr/bin/perl -w use strict; use warnings; use JavaScript; use PIL2JS::JSPM; use UNIVERSAL::require; my $rt = JavaScript::Runtime->new; my $ct = $rt->create_context; =head1 NAME jsperl - a wrapped javascript interpreter that supports Perl5 =head1 SYNOPSIS $ jsperl Perl5.perl_use("IO::File"); f = Perl5.perl_eval("IO::File->new('>file.txt')"); perl_call_method(f, "print", "fnord\\n") =head1 DESCRIPTION This is a wrapper around JavaScript.pm, which exports a Perl5 class that has three methods: C, C, C. The embeded JavaScript engine is capable for round-tripping perl5 closures, and exports three functions: C, C, C You need a modified version of L perl module, L. =cut PIL2JS::JSPM::init_js_for_perl5($ct); our $MAGIC_NOLF = "#PIL2JS // IGNORE NEXT LINEFEED#"; $ct->bind_function( name => 'print', func => sub { my $line = shift; $line =~ s/$MAGIC_NOLF//; print $line; }); local $/; my $foo = <>; $ct->eval($foo); END { $ct->destroy; } =head1 AUTHORS Chia-liang Kao Eclkao@clkao.orgE =head1 COPYRIGHT Copyright 2005 by Chia-liang Kao Eclkao@clkao.orgE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut