my $filename = 'file1.txt'; open my $posFile, $filename or die $!; open my $OUTFILE, '>', 'file2.txt'; @scoreIndividuals = &score( \*$file1,\*$file2); close($posFile); close($OUTFILE); #### Need to pass the contents of the file (as an array) to #### R script which does only operation on the contents #### (and R script does not read the file) exit; sub score{ ### Calculates score and writes on the file. }