File: grep_sample_code

package info (click to toggle)
freetds 1.5.5%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,960 kB
  • sloc: ansic: 102,649; sh: 5,542; xml: 4,521; sql: 1,488; makefile: 1,122; perl: 509; php: 22
file content (32 lines) | stat: -rwxr-xr-x 503 bytes parent folder | download | duplicates (6)
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
#! /usr/bin/perl -w

# A simple, not very flexible bit of Perl to extract the sample code 
# from the User Guide.  

while(<>) {
	last if /chapter id="programming"/;
}

while(<>) {
	if (/<programlisting/) {
		$C = 1;
		next;
	}
	$C = 0 if /\/programlisting/;
	last if /chapter id="acknowledgments"/;
	next unless $C;
	
	s/<!\[CDATA\[|\]\]\>//;
	
	s/<lineannotation>.+$//;
	s/<co id.+$//;
	
	s/&lt;/</g;
	s/&gt;/>/g;
	
	print;
}

__DATA__
 $Id: grep_sample_code,v 1.1 2007-12-10 05:13:11 jklowden Exp $