summaryrefslogtreecommitdiffstats
path: root/tools/sectionize.pl
diff options
context:
space:
mode:
authormones <mones>2001-09-06 17:01:36 +0000
committermones <mones>2001-09-06 17:01:36 +0000
commit8da28b416cd531437a4758f296d5b510c3a322a3 (patch)
tree93e33dc7c2eb3be5a44a36025f6d931befde0e1d /tools/sectionize.pl
parent104e6cfb4caf139416d250508001fed7438f69c1 (diff)
downloadsylpheeddoc-doc-8da28b416cd531437a4758f296d5b510c3a322a3.tar.gz
sylpheeddoc-doc-8da28b416cd531437a4758f296d5b510c3a322a3.tar.xz
sylpheeddoc-doc-8da28b416cd531437a4758f296d5b510c3a322a3.zip
Initial version of the SGML splitter
Diffstat (limited to 'tools/sectionize.pl')
-rwxr-xr-xtools/sectionize.pl37
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/sectionize.pl b/tools/sectionize.pl
new file mode 100755
index 0000000..64c2701
--- /dev/null
+++ b/tools/sectionize.pl
@@ -0,0 +1,37 @@
+#!/usr/bin/perl -w
+#
+# sectionize.pl
+# --------------------------------------------------------------
+# this script splits one SGML file into several files one per
+# section.
+# --------------------------------------------------------------
+# PROBLEMS:
+# - naming scheme is harcoded
+# - last file has no sections itself (harmless)
+# --------------------------------------------------------------
+# Any comment to: Ricardo Mones Lastra <mones@aic.uniovi.es>
+#
+
+(@ARGV > 0) or die ("Missing argument. Usage: $0 <filename>\n");
+
+open (FH,"<$ARGV[0]");
+my $fn = $ARGV[0];
+$fn =~ s/\.sgml//;
+my $sc = 1;
+my $ofn = join ('.', $fn, sprintf("%.03d",$sc), 'sgml');
+open (OF,">$ofn");
+while (<FH>) {
+ if (m#^</sect>*$#) {
+ print OF $_;
+ close (OF);
+ $sc = $sc + 1;
+ $ofn = join ('.', $fn, sprintf("%.03d",$sc), 'sgml');
+ open (OF,">$ofn");
+ }
+ else {
+ print OF $_;
+ }
+}
+close (OF);
+close (FH);
+print "Done. $sc sections processed\n";