1 #!/usr/bin/perl -w
2
3
4 foreach $path (@ARGV) {
5 $writing = 0;
6
7 if (!open(IN, $path)) {
8 print "trying to open $path: $!\n";
9 next;
10 }
11
12 while ($line = <IN>) {
13 if ($line =~ /EXAMPLE (\w*) ([\w\-\.]*)/) {
14 $command = $1;
15 $filename = $2 . ".example";
16
17 if ($command eq 'START') {
18 if ($writing == 0) {
19 if (!open(OUT, ">>$filename")) {
20 print "trying to write to $filename: $!\n";
21 } else {
22 print "$path: writing to $filename\n";
23 $writing = 1;
24 }
25 } else {
26 print "$path: got $line while already writing!\n";
27 }
28 }
29
30 if ($command eq 'STOP') {
31 if ($writing == 1) {
32 close(OUT);
33 $writing = 0;
34 } else {
35 chomp($line);
36 die "$path line $.: got $line when not writing!\n";
37 }
38 }
39 } else {
40 if ($writing && $line !~ /SKIPLINE/) {
41 print OUT $line;
42 }
43 }
44 }
45 if ($writing) {
46 close(OUT);
47 }
48 close(IN);
49 }
50
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.