print "
Content-type: text/html \n\n";
my @lines = split /\n/, $content; #--content = above XML data
my $depth=0; my @myarray; my $currVar; #--Declare/Set
foreach my $line (@lines) {
if($line =~ m/\?xml version/) {
# DO NOTHING as this is useless header info
} elsif($line =~ m/\<(.*)\>(.*)\<\/.*\>/) { #--THIS is DATA
$currVar=\$myarray; #--Create reference to main array
for ($i = 1; $i <= $depth; $i++) { #--Create the variable reference
$currVar=\@currVar[$arrayKey[$i]];
}
$currVar[$1]=$2;
} elsif($line =~ /^\s{0,4}\<\/(.*)\>/) { #--Array depth decrease
$depth--;
} elsif($line =~ /^\s{0,4}\<(.*)\>$/) { #--Array depth decrease
$depth++;
$arrayKey[$depth]=$1; #--Keep track of the variable names according to depth
}
}
print "
STATUS = ".$myarray[GeocodeResponse][status]." <---THIS should say OK";