# Running latex through perl batch file

I am interested in running multiple latex files in a directory from perl. I will have as many as 100 .tex files to run at once, and I was wondering if someone could suggest a perl script or package that I could modify to do this quickly.

I am planning on generating the .tex files using exceltex (since it is a large database of questions), and then executing the perl script on the folder to generate the .pdf files.

Any advice would be appreciated.

-
This shouldn't be too hard to do. But the exact method will depend on your directory/file structures. For example, will perl be called on all the files in some base directory? If not, is it possible to build a database of files you want to process through LaTeX? – A.Ellett Aug 8 '13 at 5:27
I think this is off-topic: while I see you got what looks like a good answer, it's not at all about TeX or something that TeX expertise helps with. – Joseph Wright Aug 8 '13 at 7:13
Hi Joseph: I guess I see what you mean, but I posted it here in case there was a .tex package that might help me do this. I didn't even know that exceltex existed before this forum. So, I'm sorry if this appeared to be an off-topic post. – MeTutel Aug 8 '13 at 13:17

## 1 Answer

If you're going to process all files in a directory, you can do something along the lines of

``````#!/usr/bin/perl
use strict 'vars';
my @files = <*.tex>;
foreach my \$file ( @files )
{
system("pdflatex \$file");
}
``````

Or if you have some file, call it `tobe_compiled.txt`, which lists names of file:

``````file_01.tex
file_02.tex
file_03.tex
``````

Then you could write a perl script as

``````#!/usr/bin/perl
open FILE, "<tobe_compiled.txt";
my @files = <FILE>;
close FILE;
foreach my \$file ( @files )
{
system("pdflatex \$file");
}
``````
-