]> git.lyx.org Git - lyx.git/blob - development/cmake/doc/ReplaceValues.pl
Fix screen display of parts and chapters in default classes
[lyx.git] / development / cmake / doc / ReplaceValues.pl
1 #! /usr/bin/env perl
2 # -*- mode: perl; -*-
3
4 use strict;
5
6 # Syntax: ReplaceValues.pl [<var1>=<Subst1> [<var2>=<Subst> ...]] <Inputfile> [<Inputfile> ...]
7
8
9 # Parse Arguments for strings to substitute
10
11 my %Subst = ();
12
13 for my $arg (@ARGV) {
14     if ($arg =~ /^([^=]+)=(.*)$/) {
15         $Subst{$1} = $2;
16     }
17     else {
18         # $arg should be filename here
19         &SubstituteDataInFile($arg);
20     }
21 }
22
23 exit(0);
24
25 #################################################################
26 sub SubstituteDataInFile($)
27     { my ($InFile) = @_;
28       open(FI, '<', $InFile) || die("Could not read \"$InFile\"");
29       while (my $l = <FI>) {
30           print &SubstituteDataInLine($l);
31       }
32       close(FI);
33   }
34
35 sub SubstituteDataInLine($)
36         {my ($line) = @_;
37          my $result = $line;
38          for my $k (keys %Subst) {
39             while ($result =~ s/\b$k\b/$Subst{$k}/) {
40             }
41          }
42          return($result);
43      }