This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Automatic Stdin From Cmd During Perl Execution

I need to run a perl program multiple times. My file perl.pl takes a input file as STDIN (different name each time) How can I handle all executions in one go via command drive.

(Note: I have prepared "command.bat" batch file to do this but it does not take stdin before perl execution, while I need to give that input filename before execution)

Please help, Thanks for reading.

perl

This is not a bioinformatic question.

1 answer

If you have input files bar1 through bar5, and foo is your script, use the < operator to pass those files as STDIN to foo:

#!/usr/bin/env perl
use strict;
use warnings;

system("foo < bar1") == 0 or die "could not run foo on bar1\n";
system("foo < bar2") == 0 or die "could not run foo on bar2\n";
...
system("foo < bar5") == 0 or die "could not run foo on bar5\n";

Log in to answer this question.