my $file = "xxxx.cvs"; open(my $fh, "<", $file) or die "Cannot read '$file': $!"; my $line = <$fh>; chomp($line); my @fields = split /\t/, lc($line), -1; while ($line = <$fh>) { chomp($line); my %row; @row{@fields} = split /\t/, $line, -1; # save to a db }