?xml version OK street_address 1600 Amphitheatre Pkwy 1600 1600 street_number #### mytable = { [GeocodeResponse] = { [result] = { [type] = "street address", [formatted_address] = "1600 Amphitheatre Pkwy", [address_component] = { [long_name] = 1600, [short_name] = 1600, [type] = "street_number" } } } }; #### if(length($content) >= 10 && $content =~ m/\OK\<\/status\>/) { my @lines = split /\n/, $content; $depth=0; %myarray = (); $arrayKey = {}; foreach my $line (@lines) { if($line =~ m/\?xml version/) { # DO NOTHING } else { if($line =~ m/\<(.*)\>(.*)\<\/.*\>/) { $arrayLoc = \%myarray; for ($i = 1; $i < $depth; $i++) { local $k=$arrayKey[$i]; if(!$arrayLoc->{$k}) { $arrayLoc->{$k}=() } $arrayLoc=$arrayLoc{$k}; } } elsif($line =~ /^\s{0,4}\<\/(.*)\>/) { $depth--; $arrayKey[$depth]=$1; } elsif($line =~ /^\s{0,4}\<(.*)\>$/) { $depth++; $arrayKey[$depth]=$1; } } } }