#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; my @a = ('rev','test','neko'); my @c = ( {'beji'=>'bej','neko'=>'nek','rev'=>'re','test'=>'tes'}, {'beji'=>'bej2','neko'=>'nek3','rev'=>'re4','test'=>'tes5'} ); my $g = {}; foreach my $cc (@c){ my $b = 1; foreach my $d (@a){ $b = {$cc->{$d} => $b}; } $g = $b; } warn Dumper $b;