in reply to Building a text dbm
#!/usr/bin/perl -w use strict; my(@fields) = qw/field1 field2 .../ ; # all 21 of your fields CAREFULL +Y checked open(FH, "<control.txt") or die "yada... $!"; my($rec) ; while (<FH>) { @$rec{@fields} = split /:/ ; # hash slice into an auto-vivified has +h-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} ;
|
|---|