Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Perl 5.8 to 5.16 and HASH error

by ig (Vicar)
on Sep 12, 2012 at 20:00 UTC ( #993299=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Perl 5.8 to 5.16 and HASH error
in thread Perl 5.8 to 5.16 and HASH error

From your Dumper output you can see that $Xml->{data} is a reference to an array, not a hash.

You can either change your code to produce the hash reference as it did before or change your code to work with the array as you are getting now. Which will be easier for you I can't say, having seen so little of your code.

I would look carefully to see why the second hash in the array appears: the one with a single key 'XxX'. That key looks a little odd to me. Perhaps someone added some 'test' data to the input?

One option would be to ignore the second and any other hashes that might appear in the array and process only the first one. This would be an easy next step at least, and you could always make further changes later.

To process the first hash, you can change your loop to something like:

foreach $key (keys %{$Xml->{data}->[0]}){ $sql1.="`$key`,";$sql2.="`$key`=?,";$sql3.='?,'; }


Comment on Re^3: Perl 5.8 to 5.16 and HASH error
Select or Download Code
Re^4: Perl 5.8 to 5.16 and HASH error
by robsgoingmad (Initiate) on Sep 14, 2012 at 18:15 UTC

    Hi

    I am going to go away and check the data. Thanks for all the useful help. The XxX is ok, but I need to investigate myself its exact purpose.

    Back in touch when I have checked

    Have a good weekend

    Regards

    Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993299]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2014-07-30 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (237 votes), past polls