So, I tried a number of things all of which failed. This is how I got it to work for me:
> perl -le 'printf "%.4f\t%.4f\n", rand(), rand() for 1 .. 20' \
| R --vanilla --slave -e\
"data=read.delim(pipe('cat /dev/stdin'), header=F);\
cor.test(data\$V1, data\$V2)"
You have to remember to escape any special characters in the R script (
$ in this case).