OK postal_code Edmonton, BC V2M 4M7, Canada V2M 4M7 V2M 4M7 postal_code 29.1153940 -133.8394480 #### 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"; ##
## $myarray=[GeocodeResponse]=[ status="OK", result=[ type="postal_code", formatted_address="Edmonton, BC V2M 4M7, Canada", address_component=[ long_name="V2M 4M7", short_name="V2M 4M7", type="postal_code" ], geometry=[ location=[ lat=29.1153940, lng=-133.8394480 ], ], ], ] #### # creates a single array, not an array of arrays my @array_of_arrays = ( 1 .. 10, ( 11 .. 20, ( 21 .. 30 ) ) ); #### @array_of_arrays = ( status="OK", result=( type="postal_code", formatted_address="Edmonton, BC V2M 4M7, Canada", address_component=( long_name="V2M 4M7", short_name="V2M 4M7", type="postal_code" ), geometry=( location=( lat=29.1153940, lng=-133.839448 ) ) ) )