File: include_html.pl

package info (click to toggle)
crossfire 1.1.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 11,776 kB
  • ctags: 5,507
  • sloc: ansic: 55,776; sh: 2,694; lex: 1,778; perl: 1,710; makefile: 1,518
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);