The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

JSPL::Runtime::Stock - Plugin that install stock services for JavaScript side

JAVASCRIPT INTERFACE

This plugins automatically install the following services in the global object of every context created in the referenced runtime.

To use any of the methods marked as Restricted you must call in a unrestricted context, otherwise the method invocation throws an error.

Sys Object

Alias to the global object, so if in a different scope you need to reference any of the following services, you can use Sys. as a prefix. Think in the window object when in the browser.

Env Object

The environment variables under which your program is running. You can change the properties on this object to modify the environment.

This object is an alias to perl's "%ENV" in perlvar.

IO Object

Used to aggregate all properties related to I/O

IO.File ( FILENAME [,MODE [, PERMS]] ) Constructor Function

Returns a new instance of a IO::File perl object. Please read "METHODS" in IO::File, IO::HANDLE and IO::Seekable for all the details.

IO.File.new_tmpfile ( ) Function

Returns a new instance of a IO::File opened for read/write on a newly created temporary file. On systems where this is possible, the temporary file is anonymous (i.e. it is unlinked after creation, but held open).

Write to STDOUT. Alias to "print" in perlfunc.

say ( STRING [, ...]) Function

Like print but adds a newline at the end of its arguments. Alias to "say" in perlfunc in perl 5.10+

sprintf ( FORMAT, LIST ); Function

Returns a string formatted by the usual "printf" conventions of the C library function "sprintf". This is implemented by "sprintf" in perlfunc.

peval ( STRING ) Function Restricted

Perl eval. Eval the STRING as perl code using "eval" in perlfunc. Returns the value of the last statement in STRING. If perl's eval fails, throws an exception.

system ( COMMAND [, ARG1 [, ... ]] ) Function Restricted

Alias for perl's "system" in perlfunc.

caller Function

Alias for perl's "caller" in perlfunc.

include ( FILENAME ) Function

Includes some other javascript file filename

require ( BIND, PACKAGE [, CONSTRUCTOR] ) Function Restricted

Load the perl library named PACKAGE and bind it to the javascript property BIND. The value bound will be either a PerlSub if a constructor was found in the perl package or a Stash otherwise. You must read the discussion on "install" in JSPL::Controller.

Example, requiring a package with a constructor:

    require('INET', 'IO::Socket::INET');
    // INET instanceOf PerlSub === true
    var conn = new INET(...);

When a Stash is bound it can be used to call class methods on it, among other things.

Example, requiring a package without a constructor:

    require('DBI', 'DBI');
    var conn = DBI.connect(...);

See JSPL::Controller and JSPL::Stash for the details.

load ( MODULE [, ... ]) Function Restricted

The require service described above is actually implemented in terms of two lower-level services: load and install.

The load service makes the given list of perl libraries to be loaded in the perl side. The return value of load is the number of modules loaded. If a module fails to load an exception will be thrown.

This service doesn't make the modules to be available to the javascript side. To make them available see install below.

install ( BIND, PACKAGE [, CONSTRUCTOR] ) Function

As discussed above, require is defined in terms of load and install. Install makes a perl module to be available on the perl side. The module should be previously been loaded using "load". You should read the discussion on "install" in JSPL::Controller.

Separating the "load" and the install operations is useful in certain cases. For example, for perl libraries that make available more than one perl package. Take, for example, the Gtk2 module. Loading the Gtk2 module makes available several other namespaces: Gtk2::Window, Gtk2::Button, etc... Making this module available to javascript you need to do a single load operation for Gtk2, and a bunch of install operations for the namespaces interesting to you. You should read the discussion on "install" in JSPL::Controller.

warn ( STRING [, ... ]) Function

Emit a warning message to STDERR. Alias to "warn" in perlfunc.