in reply to Re: Parsing Yahoo XML Response
in thread Parsing Yahoo XML Response

thank you for the answer, but I wasn't able to understand all of your suggestions, despite what seems like a very well written set of suggestions. Believe me it's my ignorance to this.
Did you mean that I should change the for loop to:
for( ref $doc->{Result} eq "HASH"?keys %{$doc->{Result}}:ref $doc->{Re +sult}eq "ARRAY"?@{$doc->{Result}}:() ){
?? If so, I still get the same error. Is there another way to run the loop? Thanks!

Replies are listed 'Best First'.
Re^3: Parsing Yahoo XML Response
by GrandFather (Saint) on Jan 06, 2007 at 10:09 UTC

    In that case I suggest that you try the "expanded" version of the line - that will be much easier to diagnose. If you still have trouble try generating a code sample that demonstrates the problem without requiring the extranious code. Something like this:

    #!/usr/bin/perl -w use strict; my $doc = {Result => {first => 1, second => 2} #['first', 'second'] }; my @list; if (ref $doc->{Result} eq "HASH") { @list = keys %{$doc->{Result}}; } elsif (ref $doc->{Result} eq "ARRAY") { @list = @{$doc->{Result}}; } else { @list = (); } for (@list) { print "$_\n"; }

    which prints the following (without errors or warnings):

    first second

    You might also like to use Data::Dump::Streamer to dump the contents of $doc so that you can see what is causing grief in the data.


    DWIM is Perl's answer to Gödel
      GOT IT!!
      I understand what you were saying now, MANY thanks for that secondary followup post. It really helped me understand what you meant before, and really edificated me.
      thanks again!!!