++ed by:
1 non-PAUSE user
Author image Salvador Ortiz


JSPL::Tweaks - "JavaScriptification" tweaks for Perl modules


Although JSPL try to make easy to use perl code from JavaScript land, not every Perl API can be used from JavaScript without changes.

Consider for example the perl's "read" in perlfunc, it expects a SCALAR as its second argument to use as the buffer into which the characters will be read. Thats work because in perl a subroutine decide if its arguments are received by value or by reference.

But in JavaScript all primitives are immutable and always passed by value. So perl's "read" function can't be used in its current form, it needs a specialized wrapper.

When you use "install" in JSPL::Controller to bind a perl module into JavaScript land, a "Tweaks file" will be searched, and evaluated if found.

That file can overrides the default bindings of the module to adapt it to JavaScript semantics.

For example, when you bind the "IO::Handle" module, JSPL engine will search for a file JSPL/Tweaks/IO/Handle.js in every directory in @INC. That file should returns an Object with the wrapper needed for the IO::Handle's "read" method.