3 # POD currently doesn't support any sort of =include directive. This
4 # processor works around that limitation. It takes a list of files ending in
5 # *.in as its argument and processes any POD directives of the form =include
6 # <file> in that file, generating a file with the *.in suffix removed. All
7 # paths are taken to be relative to the directory containing the file being
10 # Currently, only single include nesting is supported. The included file is
11 # not processed for additional =include statements.
16 use File::Basename qw(dirname basename);
19 for my $file (@ARGV) {
20 chdir $start or die "cannot chdir to $start: $!\n";
21 my $dir = dirname ($file);
23 unless ($out =~ s/\.in\z//) {
24 die "input file $file does not end in .in\n";
26 open (FILE, "< $file") or die "cannot open $file: $!\n";
27 open (OUT, "> $out") or die "cannot open $out: $!\n";
28 chdir $dir or die "cannot chdir to $dir: $!\n";
32 if (/^=include\s+(\S+)/) {
33 open (INCLUDE, "< $1") or die "cannot open $1: $!\n";
35 print OUT <INCLUDE> or die "cannot read/write from $1: $!\n";
36 close INCLUDE or die "cannot read from $1: $!\n";
37 print OUT "\n" or die "cannot write to $out: $!\n";
39 print OUT $_ or die "cannot write to $out: $!\n";
42 close OUT or die "cannot write to $out: $!\n";
43 close FILE or die "cannot read from $file\n";