#!/usr/bin/perl -w use strict; open (EXCEPT, "<../../ExceptionCodes.txt") or die "Can't open ../../ExceptionCodes.txt: $!\n"; open (DOCBOOK, ">ExceptionCodes.xml") or die "Can't open Exceptioncodes.xml for writing: $!\n"; print DOCBOOK < Exception codes EOD my $sectionName; my $sectionNum; my $sectionDesc; my $exceptionCode; my $exceptionShortDesc; my $exceptionLongDesc; while() { next if(m/^#/); chomp; if(m/^EXCEPTION TYPE (\w+) (\d+)/) { $sectionName = ucfirst(lc($1)); $sectionNum = $2; if($sectionName ne "Common") { $sectionDesc = "the " . $sectionName; } else { $sectionDesc = "any"; } print DOCBOOK < $sectionName Exceptions ($sectionNum) These are exceptions that can occur in $sectionDesc module of the system. EOD } # The END TYPE line if(m/^END TYPE$/) { print DOCBOOK " \n \n"; } # The actual exceptions if(m/(\(\d+\/\d+\)) - (\w+ \w+)(?: - )?(.*)$/) { $exceptionCode = $1; $exceptionShortDesc = $2; $exceptionLongDesc = $3; print DOCBOOK " \n "; print DOCBOOK $exceptionCode . ": " . $exceptionShortDesc . ""; if($exceptionLongDesc ne "") { print DOCBOOK " -- " . $exceptionLongDesc; } print DOCBOOK "\n \n"; } } print DOCBOOK "\n"; close EXCEPT; close DOCBOOK;