This is apparently a special interest topic. In case you ever need to do statistical analysis that's beyond the scope of Perl, R is pretty much the number one Open Source statistical software to use (but lacks well-established interfaces with other languages, while some "under-development" ones mostly for Linux can be found at Omegahat).

And in case you ever have some sales people ask you to recompute something all the time and email them the results in spreadsheet, you may simply want to put the stuff up on the intranet and let them do the computation themselves via a browser.

Hence come Perl and R. Here a sample CGI script, in case you're still interested:

#---------------------File Name: simpleR.pl------------------- #! /usr/local/bin/perl -w use Apache::Request () ; use strict ; # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # You only need to modify this: my $Rpath = "C:\\R\\rw\\bin\\" ; # path to rterm.exe # The rest will hopefully run itself. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # to execute R cmd: R($Rpath, $R_cmd) sub R { my $Rpath = shift ; my $Rcmd = $Rpath . "rterm --vanilla --quiet --slave" ; my $Rscript = shift ; $Rscript =~ s/(\r|;\r)/ ;/gm ; $Rscript =~ s/<-/=/gm ; # \r or +<- break "echo" return `echo $Rscript | $Rcmd` ; } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - my $r = shift ; # Apache stuff my $q = Apache::Request->new($r) ; # Apache Query obj my $command = $q->param('command') ; my $result = $command ? R($Rpath, $command) : "You didn't input any co +mmand." ; # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - print "Content-type: text/html\n\n"; print <<"EOF"; <html><body> <form method="get" action="./simpleR.pl"> Please enter your R command:<br> <textarea rows="4" name="command" cols="60">$command</textarea +><br> <input type="submit" value="Submit"> </form><br> <textarea rows="10" name="result" cols="80">$result</textarea> </body></html> EOF exit;

In reply to Statistical Analysis via Browser by chunlou

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.