File: include_html.pl

package info (click to toggle)
crossfire 1.11.0-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 24,456 kB
  • ctags: 7,800
  • sloc: ansic: 80,483; sh: 11,825; perl: 2,327; lex: 1,946; makefile: 1,149
file content (33 lines) | stat: -rw-r--r-- 469 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl

# basic 

$in = $ARGV[0];
$out = $ARGV[1];
sub die {
    $prog = $0;
    print STDERR $prog.": ".$_[0]."\n";
    exit(1);
}

open(FOUT,">".$out) || &die("cannot open ".$out);


sub include_file {
    $in = shift;
    local(*FIN);
    open(FIN,"<".$in) || &die("cannot open ".$in);
    while (<FIN>) {
	if (/^<!--#include file="(.*)"-->$/) {
		&include_file($1);
	}
	else {
		print FOUT $_;
	}
    }
    close(FIN);
}

&include_file($in);
close(FOUT);