my @fieldname = ('one','seat','three'); =pod the structure we are aiming for might be: @lines = ( { $fieldname => $value, $fieldname => $value, $fieldname => $value, }, { $fieldname => $value, $fieldname => $value, $fieldname => $value, }, { $fieldname => $value, $fieldname => $value, $fieldname => $value, }, ); thus.. line 3 field "seat" is gotten to like $lines[2]->{'seat'}; the order of the @lines array tells you which line it is, inside it are anonymous hashes that have the key value pairs to what was found inside. You're going to probably run into some undef problems, because of the commas. you can ouput the scv diff ways, I would maybe output it with forced quote chars, even if empty. Then all your values have the quote chars inside, which you could remove later. This whole thing would be paintful, but fun. =cut for (@lines){ my @vals = split(/,/,$_); my $line = {}; my $x=0; for (@vals){ $line->{$fieldname[$x]} = $_; $x++; } push @lines, $line; }