#!/usr/bin/perl use strict; use warnings; use DBI; my $dbh=DBI->connect('DBI:mysql:database=test;host= localhost','root','mypassword',{RaiseError =>1,AutoCommit=>1},); my $sql='INSERT INTO foo(Item1,Item2)VALUES(wahed,jouj)'; my $sth=$dbh->prepare($sql); while(){ chomp; my @vals=split /\s+/, $_; $sth->execute(@vals); }