#!/usr/bin/perl -w use strict; my(@fields) = qw/field1 field2 .../ ; # all 21 of your fields CAREFULLY checked open(FH, ") { @$rec{@fields} = split /:/ ; # hash slice into an auto-vivified hash-reference (instant record) $recs{"$rec->{field13}$rec->{field21}"} = $rec ; } ## ## Individual records can be manipulated by field name ## $rec{keyOfInterest}->{fieldOfInterest} = NewValue ; ## ## to convert a rec back into a string: ## my($str) = join ":", @$rec{@fields} ;