in reply to Initializing Hashes of Hashes (of Hashes)

Right, first off the bat - heed PodMaster's advice. What you are doing here does not make much sense: leaf nodes with the same path leading to them as earlier nodes will overwrite those nodes. Also, I don't know how CGI is supposed to handle a.b.c=1&a.b.c=2, but CGI.pm concatenates the values, which does not seem to be what you want.

That said, here's some code that does what you ask, although it does not make much sense :) :

use warnings; use strict; use CGI; use Data::Dumper; my $cgi = CGI->new( 'a.b.c=3&d.e.f.g=5&x.y=4' ); my %params=$cgi->Vars(); my %hash; while (my ($param,$value) = each %params ) { my $hashref=fill($param,$value); my $key=(keys %$hashref )[0]; $hash{$key}=$hashref->{$key}; } print Dumper(\%hash); sub fill { my $node=shift; my $value=shift; my @nodetree=split /\./, $node; if (scalar @nodetree == 1) { return { $nodetree[0] => $value } }; my $trunk=shift @nodetree; $node=join ".", @nodetree; return { $trunk => fill($node,$value) }; } __END__ $VAR1 = { 'a' => { 'b' => { 'c' => '3' } }, 'd' => { 'e' => { 'f' => { 'g' => '5' } } }, 'x' => { 'y' => '4' } };

Update: Scratch that remark wrg multiple values for the same param. My conclusion was based on an incorrect test of mine.

CU
Robartes-