my @array = qw( FirstName LastName MiddleName LegalInd DateOfBirth Sex Race Ethnicity Height Weight Build Eyes Hair SocSecNo MaritalStatus PlaceOfBirthCity PlaceOfBirthState AddressType DfAdate StreetNumber StreetName StreetType City State Zip ); for (@array) { $xml_writer->dataElement("$_" => $t{A}{$_}); }