in reply to Perl & R ?

This is untested since I don't have R, but something like this ought to work:
open my $proc, "| R" or die "cannot open process R: $!"; autoflush $proc; print $proc "source(\"commands.R\")\n"; close $proc;
This forks off a subprocess running R and then writes the command to its standard input through a pipe. This assumes that R is able to accept input through a pipe (ie it doesn't presume a terminal), but it will probably work. See perlopentut for more.

Replies are listed 'Best First'.
Re^2: Perl & R ?
by Jaya (Acolyte) on Mar 29, 2005 at 06:14 UTC
    I am working on linux machine and i cannot install the R/Splus-Perl Interface because I need root access for it!!i tried the fork code you gave me. I am getting this error

    Fatal error: you must specify `--save', `--no-save' or `--vanilla' Fatal error: you must specify `--save', `--no-save' or `--vanilla' Fatal error: you must specify `--save', `--no-save' or `--vanilla' Broken pipe
    is this error because of the special shell character > , if so how to solve it

    Thank You

      Just curiously, have you tried:
      system("R commands.r")
        Yes. I did. That was the first thing i tried.