File: updatecode.pl

package info (click to toggle)
semweb 1.05%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,988 kB
  • ctags: 2,832
  • sloc: cs: 14,483; makefile: 180; sh: 107; perl: 20; ansic: 7
file content (25 lines) | stat: -rw-r--r-- 533 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl

opendir D, ".";
foreach $f (readdir(D)) {
	if ($f !~ /\.html$/) { next; }
	$content = `cat $f`;
	
	$content =~ s/<pre class="code" file="([^"]+?)">([^<]*?)<\/pre>/"<pre class=\"code\" file=\"$1\">" . GetFile($1, $2) . "<\/pre>"/egi;
	
	open F, ">$f";
	print F $content;
	close F;
}
closedir D;

sub GetFile {
	print "$f <-- $_[0]\n";
	if (!-e $_[0]) { warn "File not found: $_[0]"; return $_[1]; }
	my $d = `cat $_[0]`;
	$d =~ s/\&/\&amp;/g;
	$d =~ s/</\&lt;/g;
	$d =~ s/>/\&gt;/g;
	$d =~ s/\t/    /g;
	return $d;
}