Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^5: Hash of Arrays or Arrays of arrays? and how proceed?

by jethro (Monsignor)
on Aug 02, 2011 at 11:13 UTC ( [id://918014]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Hash of Arrays or Arrays of arrays? and how proceed?
in thread Hash of Arrays or Arrays of arrays? and how proceed?

The uninitialized value in hash element(!) would be $database. In such cases it is a good debugging technique to add statements like the following to your code to observe what happens:

use Data::Dumper; #at the start of the script ... print Dumper(\$database,\$nextfield,\@fields); $result{$database}{next}= $nextfield; $result{$database}{fields}= \@fi +elds; #<--- the problematic line

A simple print "\$database is $database\n" would do as well, but Data::Dumper is to print for debugging like a lawnmower is to a scissor for cutting gras ;-).

Look at the output and compare it to your expectations. Probably you will see an undef value printed for $database. Now you can retrace the steps, look how $database could get that value, insert "print Dumper..." statements where you think it could go wrong. Maybe it is a regex that didn't match anything or maybe you put a value in an array into $a[1] but not in $a[0], which would leave the first array value undefined...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2024-04-18 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found