tie $dbfh, 'Tie::DBI', $dsn, $user, $pass, 'id, name from foo';
while (my $record = <$dbfh>) {
print "ID: ", $record->{id}, "\n";
print "Name: ", $record->{name}, "\n";
}
####
# $dbfh continues from above
$dbfh->print(join $/, (id => '42', name => 'Answer', '');
####
my $dbfh = tie $dbfh, 'Tie::DBI', $dsn, $user, $pass, 'id, name from foo'; # Support optional prameters to give the defintion of comma, newline, etc? Take ideas from CSV_XS
while (<$dbfh>) {
chomp;
my ($id, $name) = split /,/, $_;
print "$id: $name\n";
}
print $dbfh (qq(42, "Answer"\n));
# Note that the \n isn't optional; you should wait for it, putting input in an interal buffer until you see it, then flush the whole line. Support some special syntax to specifiy a NULL, or to leave it out and let an AUTONUMBER column do it's thing?