use DBI; use strict; my $db = DBI->connect("DBI:CSV:"); # create table $db->do("create table testdb (NAME CHAR(20),POSTAL CHAR(20),TELEPHONE CHAR(20))"); # create dummy data my $sth=$db->prepare("insert into testdb (NAME,POSTAL,TELEPHONE) VALUES (?,?,?)"); for (1..10) { $sth->execute("name $_","postal $_","telephone $_"); } # update 2 lines of data with different format statements my $sth1 = $db->prepare("update testdb set NAME=?,POSTAL=?,TELEPHONE=? where name=?"); my $sth2= $db->prepare("update testdb set POSTAL=?,TELEPHONE=? where name=?"); $sth1->execute("name 9","postaladdress","123456","name 9"); $sth2->execute("postaladdress","123456","name 10"); # display the contents of testdb my $sth3 = $db->prepare("select * from testdb"); my $result = $sth3->execute(); my $line; while ($line = $sth3->fetchrow_arrayref) { for my $attrib (@$line) { print "$attrib\t"; } print "\n"; } #### my $db = DBI->connect("DBI:SQLite:dbname=testfile","",""); #### name 1 postal 1 telephone 1 name 2 postal 2 telephone 2 name 3 postal 3 telephone 3 name 4 postal 4 telephone 4 name 5 postal 5 telephone 5 name 6 postal 6 telephone 6 name 7 postal 7 telephone 7 name 8 postal 8 telephone 8 name 9 name 9 postaladdress name 10 name 10 postaladdress #### name 1 postal 1 telephone 1 name 2 postal 2 telephone 2 name 3 postal 3 telephone 3 name 4 postal 4 telephone 4 name 5 postal 5 telephone 5 name 6 postal 6 telephone 6 name 7 postal 7 telephone 7 name 8 postal 8 telephone 8 name 9 postaladdress 123456 name 10 postaladdress 123456