generate-text-files.pl 626 Bytes
Newer Older
1
#!/usr/bin/perl -w -*- perl -*-
bk@work.mysql.com's avatar
bk@work.mysql.com committed
2 3 4 5 6 7
# Generate text files from top directory from the manual.

$from = shift(@ARGV);
$fnode = shift(@ARGV);
$tnode = shift(@ARGV);

8
open(IN, "$from") || die "Cannot open $from: $!";
bk@work.mysql.com's avatar
bk@work.mysql.com committed
9 10 11 12 13 14 15

$in = 0;

while (<IN>)
{
  if ($in)
  {
16
    if (/Node: $tnode,/ || /\[index/)
bk@work.mysql.com's avatar
bk@work.mysql.com committed
17 18 19 20 21
    {
      $in = 0;
    }
    elsif (/^File: mysql.info/ || (/^/))
    {
22
      # Just Skip node beginnings
bk@work.mysql.com's avatar
bk@work.mysql.com committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
    }
    else
    {
      print;
    }
  }
  else
  {
    if (/Node: $fnode,/)
    {
      $in = 1;
      # Skip first empty line
      <IN>;
    }
  }
}

close(IN);
41 42 43

die "Could not find node \"$tnode\"" if ($in == 1);
exit 0;