Our program for today...
$dbh = DBI->connect('', '', '', { RaiseError => 1 });
replace_price(split(/\s+/, $_)) while (<STDIN>);
local $dbh->{TraceLevel} = 1;
my $upd = $dbh->prepare("UPDATE prices SET price=? WHERE id=?");
my $ins = $dbh->prepare_cached("INSERT INTO prices (id,price) VALUES(?,?)");
my $rows = $upd->execute($price, $id);
$ins->execute($id, $price) if $rows == 0;
}
(The program is a little odd for the sake of producing a small trace output that can illustrate many concepts)