use Data::Dumper; my @selector = ("field1", "field2", "field3", "field4"); my @RefHash; while () { chomp; my @inLine = split /,/; my %content; @content{@selector} = @inLine; push @RefHash, \%content; } print Dumper \@RefHash; __END__ foo,bar,baz,quux one,two,three,four ichi,ni,san,shi