errdb.pl revision a734c64bff58bda2fa48c2795453e092167b0ff7
=head1 NAME
=head1 SYNOPSIS
Options:
-d,--database=db Specify path to errors.db
-h,--help Display brief help message
-v,--verbose Increase verbosity
-q,--quiet Decrease verbosity
=cut
use DBI;
use strict;
use warnings;
# Parse command-line options
my $verbosity = 0;
my $errdb = "errors.db";
'database|d=s' => sub { shift; $errdb = shift; },
'verbose|v+' => sub { $verbosity++; },
'quiet|q+' => sub { $verbosity--; },
) or die "Could not parse command-line options\n";
# Open database
$dbh->begin_work();
# Create errors table if necessary
eval {
};
if ( $@ ) {
$dbh->do ( "CREATE TABLE errors (".
" errno char(8) NOT NULL,".
" description text NOT NULL,".
" PRIMARY KEY ( errno ) )" );
}
# Create xrefs table if necessary
eval {
};
if ( $@ ) {
$dbh->do ( "CREATE TABLE xrefs (".
" errno char(8) NOT NULL,".
" filename text NOT NULL,".
" line integer NOT NULL,".
" UNIQUE ( errno, filename, line ),".
" FOREIGN KEY ( errno ) REFERENCES errors ( errno ) )" );
$dbh->do ( "CREATE INDEX xrefs_errno ON xrefs ( errno )" );
}
# Parse input file(s)
my $errors = {};
my $xrefs = {};
while ( <> ) {
chomp;
}
# Ensure all errors are present in database
my $error_update =
}
}
# Replace xrefs in database
$dbh->do ( "DELETE FROM xrefs" );
foreach my $line ( keys %$xref_filename ) {
if $verbosity >= 2;
}
}
}
# Close database
$dbh->disconnect();