#!/usr/bin/perl -w
# raw2txn 
# - converts STDIN input (which really ought to be in RAWDUMP form)
# into a set of txns fresh and ready to be processed.
# Particularly useful for system recovery.
# $Id: raw2txn,v 1.1 1994/11/14 07:05:34 cbbrowne Exp $
require "cbbshutils.pl";
while (<>) {
	($mt, $account, $key, $value, $comment) = split(/===/, $_);
	if ($comment eq "") { # Good indicator that there's a problem...
		print "# Invalid item: $_\n";
	} else {
		($date, $check, $desc, $debit, $credit, $cat, $com, $cleared, $total) =
	        split(/:/, $value);
		printf "txn %s %6s '%s' '%s' '%s' %.2f '%s'\n",
			$name, $date, $check, $desc, $cat, $debit-$credit, $com;
	}
}

