blob: 13265efece3090b8056b97e7ad14098e88de0ec7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#
# BEGIN COPYRIGHT BLOCK
# Copyright 2001 Sun Microsystems, Inc.
# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
# All rights reserved.
# END COPYRIGHT BLOCK
#
# The first argument is the file to edit
# The remaining arguments are pairs of values: the first value of the pair is
# the token to look for, and the second is the value to replace it with e.g.
# if the input file foo contains
# $NETSITE_ROOT/%%%PERL_RUNTIME%%% -w perlscript ...
# then running $(PERL) thisscript foo %%%PERL_RUNTIME%%% foo/bar/perl5 > output/foo
# will result in output/foo containing
# NETSITE_ROOT/foo/bar/perl5 -w perlscript ...
($input, %tokens) = @ARGV;
if (! $input) {
print STDERR "Usage: $ $0 <inputfilename> [token1 replace1] ... [tokenN replaceN]\n";
exit 1;
}
open(INPUT, $input) or die "Error: could not open file $input: $!";
while (<INPUT>) {
while (($key, $value) = each %tokens) {
s/$key/$value/g;
}
print;
}
close INPUT;
|