summaryrefslogtreecommitdiffstats
path: root/ast/doincludes
blob: 656b0acf6d95ddefb1d7a3e8a69cefe2e6c4db12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /usr/bin/env perl

#  Reads a Latex file which contains \include{file} commands and writes
#  the document to standard output with the text of the included files
#  inserted.

#  Read input lines.
   while ( <> ) {

#  Spot the \include{file} lines and extract the file name.
      if ( ( $file ) = /^ *\\include{(.*)} *$/ ) {

#  Read the contents of the included file.
         open( INCLUDE, $file . ".tex" );
         while ( <INCLUDE> ) { print; }
         close( INCLUDE );

#  Output other lines unchanged.
      } else {
         print;
      }
   }