#!/usr/bin/perl -w
#
# revtext.pl
#
# J. Uckelman (uckelman@iastate.edu)
# 18 October 2000
#

require 5.005;
use DBI;

my $version = 0.1;
my $config = '/home/g1/bin/scripts.conf';

# load the config file 
eval { require $config; }; die "$0: $config: $@\n" if $@;

# connect to game database
$dbh = DBI->connect($dsn, $user, $password);

my ($table, $column, $number, $oldrev, $newrev) = @ARGV[0 .. 4];

my $sth = $dbh->prepare("select $column from $table where number = $number and revision = $oldrev");
$sth->execute;
my ($data) = $sth->fetchrow_array;
$sth->finish;

open OUT, ">$TMP/tmp" or die;
print OUT $data;
close OUT;

system "vim $TMP/tmp";

open IN, "<$TMP/tmp" or die;
$data = quotemeta(join '', <IN>);
close IN;

$dbh->do("update $table set $column = '$data' where number = $number and revision = $newrev");

$dbh->disconnect;
