use Data::Dumper; while() { @array = split('\|', $_); # printing to Dumper, just to show what @array looks like now print Dumper @array; # insert DBI stuff here ... } __DATA__ |John Smith|123 Any Street||Any City|KS|23568| |Mary Smith|123 Any Avenue||Any Town|KS|32546|