#!/usr/local/bin/perl use strict; if ($#ARGV < 1) {usage();} my $logfile = $ARGV[0]; my $rptfile = $ARGV[1]; # setup output my $fopen = sprintf("Cannot open %s for output\n", $rptfile); open(rptfile, ">$rptfile") or die $fopen; # get data $fopen = sprintf("Cannot open %s for input\n", $logfile); open(logfile, $logfile) or die $fopen; my @summdat = ; close(logfile); shift @summdat; # remove unnecessary first line foreach my $summline (@summdat) { my ($junk, $id, @rest) = split /:/, $summline; $id =~ tr/a-zA-Z0-9/ /c; # remove punctuation $id =~ s/^ +//; # remove leading space my ($ida, $idb) = split / /, $id; $id = sprintf ("%-4.4s %10.10s:", $ida, $idb); my $what = ''; foreach my $item (@rest) {$what .= ':' . $item;} $what =~ s/^\://; next if $what =~ ' already in unicode'; if ($what =~ / Error.+/) { my $stop = index($what, "'"); printf rptfile ("%s %s\n", $id, substr($what, 0, $stop-1)); } else { my ($number, $data) = split /:/, $what; $number =~ s/[\(\)\[\]]/ /g; # remove ()[] $number =~ s/\s\s*/ /g; # collapse spaces down to one $number =~ s/^ +//; my ($fieldn, $whichfield) = split / /, $number; my $where = index($data, "at") + 3; my $at = ''; my $char = substr($data, $where++, 1); while ($char =~ /\d/g) { $at .= $char; $char = substr($data, $where++, 1); } my $here = length($data) - 2; # before last (') my $somechars = substr($data, $here-8, 8); # last 8 chars printf rptfile "$id "; printf rptfile ("field # %s, which is tagged %s, around char # %s", $fieldn, $whichfield, $at); if ($somechars ne '........') {printf rptfile (", something like '%s'\n", $somechars);} else {print rptfile "\n";} } } close(rptfile); sub usage() { print ("\nUsage: ulogtranslate.pl summaryfile rptfile\n\n"); print (" Reads the specified summaryfile that resulted from\n"); print (" the Voyager Unicode conversion.\n"); print (" A human readable translation of this data is put in rptfile.\n"); print (" Include the file path if needed. For example, for summaryfile\n"); print (" it might be: /m1/incoming/2005.0/INFO/dbname/summary.txt\n"); print (" where you substitute your database name of choice for \"dbname\".\n\n"); print (" [This program is designed to read the summary.txt file\n"); print (" that the Unicode conversion process creates.]\n\n"); exit(0); }