my %copy_to = ( key1 => \$key1, key2 => \$key2, key3 => \$key3, ); while(my ($key, $var) = each %copy_to) { $$var = $hash{$key}; }