# in the form HTML generating code...
my %row = # fetch row from table into a hash
foreach my $col (keys %row) {
# actually properly escape all of this stuff... I'm just writing it out sort of short-hand
print "";
}
# in the form processing code... assuming that your form values are present in a hash called %form
my %row = # fetch row from table into a hash
my (%yours,%theirs); # store colums which were updated by you, and columns which were updated by some intervening session
foreach my $col (map {/^original_(.*)/ ? $1 : ()} keys %form) {
if ($form{"original_$col"} ne $row{$col} {
# oh no! this column was updated by some intervening session
$theirs{$col} = $form{"original_$col"};
}
if ($form{$col} ne $row{$col} {
# this is a column that *you* edited
$yours{$col} = $form{$col};
}
}
if (!%theirs) {
# there were no intervening edits... process the form!
DoThing(\%form);
}
else {
# there were edits maid by another user between the time you downloaded the form and when you posted the form back
print "CONFLICTS!"; # etc let the user know what the deal is
}