Suppose you have a script that takes a couple of command-line arguments and dumps its results to stdout.
Manually invoking this script will look like this:
perl foo.pl arg1 arg2 arg3
Without changing the script in question, is it possible under Windows to take the contents of a file (e.g., input.txt is a multi-line text file with arg{1,3} delimited by a whitespace on each line) and execute something like this:
foreach line in input.txt
perl foo.pl current_line >> output.txt
Right now, I just have another Perl script that does this, but was wondering if this was possible anyway.
I’m gonna say yes.
I searched the web with Google for
windows batch loopsand got this page: http://www.robvanderwoude.com/for.php.I dug around on the site and found this page: http://www.robvanderwoude.com/ntfor.php#FOR_F
So it looks like the code would be something like…