Execute the Perl Interpreter

DESCRIPTION:

A S-PLUS utility to execute the Perl interpreter after adding some S-PLUS directories to the list of directories in which to look for Perl library files.

USAGE:

Splus CMD Sperl [switches] filename [arguments] 

REQUIRED ARGUMENTS:

filename
name of Perl script to execute.

OPTIONAL ARGUMENTS:

switches
Perl command line switches. To see all available switches:
Splus CMD Sperl -h
arguments
arguments to pass to the Perl script given by filename.

SIDE EFFECTS:

The side effects that occur will depend upon the actions of the Perl script.

DETAILS:

The Sperl utility is invoked from the operating system's command line using the S-PLUS CMD utility.

Currently Perl version 5.8, or later, is required to use Sperl. Perl source can be downloaded from this site: http://www.perl.com/download.csp. That website also has links to other sites that have binary distributions of Perl on various platforms.

The Sperl utility attempts to startup Perl by executing either the program specified by the environment variable S_PERL (if set), /usr/bin/perl , or /usr/local/bin/perl (in that order). You can specify which Perl program to use by setting the S_PERL environment variable.

These S-PLUS directories are added to the list of directories that Perl will search for Perl library files: SHOME/share/perl and SHOME/library/pkgutils/share/perl.

Other directories can be added to the list that Perl will search by setting the environment variable S_PERLLIB. If S_PERLLIB is set, then its value along with the S-PLUS directories mentioned above are added to the value of the environment variable used by Perl, either PERL5LIB or PERLLIB .

Using Sperl, the user can create scripts that use Perl functions written specifically for S-PLUS. Several Perl functions can be found in SHOME/library/pkgutils/share/perl/Splus/Utils.pm. For example, the Perl function Splus_run allows you to run S-PLUS commands from Perl scripts:
    Splus_run("splus expression", "splus options", "environment")
In order to call this function, put this line into your Perl program:
use Splus::Utils;

REFERENCES:

Schwartz, Randal L., Phoenix, Tom and foy, brian d (2005), Learning Perl, Fourth Edition, O'Reilly & Associates, Inc., Sebastopol, CA.
Schwartz, Randal L., foy, brian d, and Phoenix, Tom (2006), Intermediate Perl, O'Reilly & Associates, Inc., Sebastopol, CA.

SEE ALSO:

.

EXAMPLES:

# An example showing where Perl looks for modules
# Create a file named "showinc.pl" containing:
print "Value of \@INC:\n";
foreach $item (@INC) { 
print $item, "\n" ;
}
# Execute Sperl
Splus CMD Sperl showinc.pl

# An example using Splus_run()
# Create a file named "statenames.pl" containing:
use Splus::Vars;
use Splus::Utils;
# Will print 13 lines of state names, preceded by -->
@output=Splus_run("print(state.name)");
print " --> ", join("\n --> ", @output), "\n" ;
# Execute Sperl
Splus CMD Sperl statenames.pl

# Another example using Splus_run(), illustrating how command line
# options and environment variables can be set.
# Create a file named "mydog.pl" containing:
use Splus::Vars;
use Splus::Utils;
@output=Splus_run("Sys.getenv('MYDOG')", "--vanilla", "MYDOG=fido");
print join("is", @output), "\n" ;
# Execute Sperl
Splus CMD Sperl mydog.pl