use Data::OptList; my $options = Data::OptList::mkopt([ qw(key1 key2 key3 key4), key5 => { x => 1, y => 2 }, key5 => { a => 2, b => 4 }, ]); use Data::Dumper; warn Dumper($options); sh-3.2$ perl try.pl $VAR1 = [ [ 'key1', undef ], [ 'key2', undef ], [ 'key3', undef ], [ 'key4', undef ], [ 'key5', { 'y' => 2, 'x' => 1 } ], [ 'key5', { 'a' => 2, 'b' => 4 } ] ]; sh-3.2$ #### [ 'key5', [ { 'a' => 2, 'b' => 4 }, { 'y' => 2, 'x' => 1 } ] ]