#!/usr/bin/perl -w use strict; use DBI; open (my $FH, '<', "test.csv") or die "Cannot open test.csv: $! \n"; my $dbh = DBI->connect ("dbi:Oracle:host=;sid=", '', ',password.', { RaiseError => 1, AutoCommit => 1, TraceLevel => 4 } ) or die "Canot create Databse Handle: $DBI::errstr() \n"; my $sth = $dbh->prepare ("INSERT INTO CLUSTER_MAPPING (name, farm, dmz) VALUES (?,?,?)"); <$FH>; ### this is to remove the column headers while (<$FH>) { my @row = split /,/; my $col1_value = $row[0]; my $var1 = $row[1]; $var1 =~ s/"//g; $var1 =~ s/^ //g; my $col2_value = $var1; my $col3_value = $row[2]; $sth->execute ($col1_value, $col2_value, $col3_value); } # If this is the end of your program, these lines are unnecessary, as it'll all be # cleaned up at the end of the program. But if you're continuing to do something # else in your program, then by all means leave them in. $sth->finish(); $dbh->disconnect(); close $FH;