summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2005-12-13 12:39:44 +0000
committerfukachan <fukachan>2005-12-13 12:39:44 +0000
commitfab3c55bdc25ad686e2772f8416bb5af1be90add (patch)
tree1d444c19fe9429cc4b14ae0875f496e400233b1d
parentb8a241b5e1a876cbfe016e63b92d040aca5750f9 (diff)
downloadfml8-fab3c55bdc25ad686e2772f8416bb5af1be90add.tar.gz
fml8-fab3c55bdc25ad686e2772f8416bb5af1be90add.tar.bz2
fml8-fab3c55bdc25ad686e2772f8416bb5af1be90add.zip
list up recipes
-rwxr-xr-xregress/doc/listup_recipe.pl90
1 files changed, 90 insertions, 0 deletions
diff --git a/regress/doc/listup_recipe.pl b/regress/doc/listup_recipe.pl
new file mode 100755
index 00000000..7759b23a
--- /dev/null
+++ b/regress/doc/listup_recipe.pl
@@ -0,0 +1,90 @@
+#!/usr/bin/env perl
+#-*- perl -*-
+#
+# $FML$
+#
+
+use strict;
+use Carp;
+use vars qw($total $current_chapter_title $is_title_print);
+
+if (@ARGV) {
+ for my $file (@ARGV) {
+ read_file($file);
+ }
+}
+else {
+ read_file("/dev/stdin");
+}
+
+exit 0;
+
+sub read_file
+{
+ my ($file) = @_;
+
+ use FileHandle;
+ my $rh = new FileHandle $file;
+ if (defined $rh) {
+ my $in_q = 0;
+ my $in_t = 0;
+ my $first = 0;
+ my $num_r = 0;
+ my $buf;
+
+ while ($buf = <$rh>) {
+ next if $buf =~ /<para>/;
+ next if $buf =~ /<\/para>/;
+
+ # chapter title reset
+ if ($buf =~ /<chapter.*>/) {
+ $current_chapter_title = '';
+ $is_title_print = 0;
+ next;
+ }
+ unless ($current_chapter_title) {
+ if ($buf =~ /<title>/i) { $in_t = 1; next; }
+ if ($buf =~ /<\/title>/i) { $in_t = 0; next; }
+ if ($in_t) {
+ $buf =~ s/^\s*//;
+ $buf =~ s/\s*$//;
+ $current_chapter_title .= $buf;
+ next;
+ }
+ }
+
+ if ($buf =~ /<question>/) {
+ $in_q = 1;
+ $num_r++;
+ $total++;
+
+ unless ($is_title_print) {
+ print_chapter_title();
+ $is_title_print = 1;
+ }
+
+ unless ($first) {
+ print "\n-- $file\n" unless $file =~ /\/dev\//;
+ $first = 1;
+ }
+ print "\n($num_r)\n";
+ next;
+ }
+ if ($buf =~ /<\/question>/) {
+ $in_q = 0;
+ next;
+ }
+
+ if ($in_q) {
+ print $buf;
+ }
+ }
+ $rh->close();
+ }
+}
+
+
+sub print_chapter_title
+{
+ print "\n*** ", $current_chapter_title, " ***\n";
+}