Commit | Line | Data |
---|---|---|
34e49164 C |
1 | #!/usr/bin/perl |
2 | #usage: ./extract_examples.pl ~/week-end/working-documents/examples.tex | |
3 | ||
4 | my $ex = 0; | |
5 | my $are_in = 0; | |
6 | while(<>) { | |
7 | ||
8 | if(/\\section{/) { | |
9 | $ex++; | |
10 | open TMP, ">$ex.cocci" or die "$!"; | |
11 | } | |
12 | ||
13 | if(/begin{verbatim}/) { | |
14 | $are_in = 1; | |
15 | #old: open TMP, ">$ex.cocci" or die "$!"; | |
16 | } elsif(/end{verbatim}/) { | |
17 | $are_in = 0; | |
18 | #old: $ex++; | |
19 | } else { | |
20 | if($are_in) { print TMP "$_"; } | |
21 | } | |
22 | } |