sub foo { my ($table, $hr) = @_; ## TODO: argument checking $Data->Sql ("SELECT * FROM $table"); while ($Data->FetchRow ()) { my %x= $Data->DataHash(); $hr->{$x{ID}}{$x{DataName}}= $x{DataValue}; } } foo "ConfigData", \%ConfigData; foo "DicomDestinations", \%DestinationData;