Commit | Line | Data |
80252599 |
1 | # take a semicolon separated path list and turn it into a quoted |
2 | # list of paths that Text::Parsewords will grok |
3 | sub mungepath { |
4 | my $p = shift; |
5 | # remove leading/trailing semis/spaces |
6 | $p =~ s/^[ ;]+//; |
7 | $p =~ s/[ ;]+$//; |
8 | $p =~ s/'/"/g; |
9 | my @p = map { $_ = "\"$_\"" if /\s/ and !/^".*"$/; $_ } split /;/, $p; |
10 | return join(' ', @p); |
11 | } |
12 | |
137443ea |
13 | my %opt; |
14 | while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/) |
15 | { |
16 | $opt{$1}=$2; |
17 | shift(@ARGV); |
18 | } |
7bac28a0 |
19 | |
10609e9a |
20 | $opt{VERSION} = $]; |
21 | $opt{INST_VER} =~ s|~VERSION~|$]|g; |
c90c0ff4 |
22 | if ($] =~ /\.(\d\d\d)?(\d\d)?$/) { # should always be true |
23 | $opt{PATCHLEVEL} = int($1 || 0); |
24 | $opt{SUBVERSION} = $2 || '00'; |
25 | } |
26 | |
d484a829 |
27 | $opt{'cf_by'} = $ENV{USERNAME} unless $opt{'cf_by'}; |
28 | $opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0] |
29 | unless $opt{'cf_email'}; |
852c2e52 |
30 | $opt{'usemymalloc'} = 'y' if $opt{'d_mymalloc'} eq 'define'; |
d484a829 |
31 | |
80252599 |
32 | $opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth}; |
33 | $opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath}; |
34 | |
137443ea |
35 | while (<>) |
36 | { |
37 | s/~([\w_]+)~/$opt{$1}/g; |
dc050285 |
38 | if (/^([\w_]+)=(.*)$/) { |
39 | # this depends on cf_time being empty in the template (or we'll get a loop) |
40 | if ($1 eq 'cf_time') { |
41 | $_ = "$1='" . localtime(time) . "'\n" if $2 =~ /^\s*'\s*'/; |
42 | } |
43 | elsif (exists $opt{$1}) { |
44 | $_ = "$1='$opt{$1}'\n"; |
45 | } |
46 | } |
137443ea |
47 | print; |
48 | } |
49 | |