Call Perl from within S-PLUS

DESCRIPTION:

Calls Perl from within S-PLUS, passing data from S-PLUS to the Perl program and reading the output from Perl back into S-PLUS.

USAGE:

perl(command=character(), input=character(), perl.args=character())

OPTIONAL ARGUMENTS:

command
a character string containing the Perl code to execute.
input
a S-PLUS object containing the input to the Perl code. A file for input to Perl will be created with the command: cat(file = infile, input, sep = "\n")
perl.args
command line arguments for Perl.

VALUE:

a character vector containing the output from the Perl command. Each element of the vector is a one line of output from Perl. If there is any output to standard error from Perl, it is returned in the attribute "stderr".

SIDE EFFECTS:

No side effects unless the Perl code has side effects.

DETAILS:

You must have Perl installed on your system for this function to work. See the references to download and install Perl.

A call to Perl is constructed from the input arguments and then call is invoked through unix or system. The call to Perl is through the Sperl utility which adds S-PLUS specific directories to Perl's include search. The command constructed is: Sperl perl.args commandfile < infile > outfile 2> errfile where infile contains the values in input, one element per line. The output from outfile and errfile is then read back into S-PLUS.

REFERENCES:

Perl.com web site: http://www.perl.com. This site contains links for downloading Perl as well as Perl documentation.

Schwartz, Randal L., Phoenix, Tom and Foy, Brian D. 2005. Learning Perl, 4th ed. O'Reilly Media: California.

SEE ALSO:

, (on Unix), (on Windows).

EXAMPLES:

# What version of Perl do I have:
perl(perl.args="--version")

# The -p flag to Perl processes and prints each line of input,
#   this just returns LETTERS:
perl(perl.args="-p", input=LETTERS)