Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Data::Dumper in a nutshell for debugging/learning.
In some ways I see Data::Dumper as a debugging tool, yet it has many uses beyond. I most frequently use the exported Dumper function. You feed it a data structure (array,hash,etc) or a complex data structure (hashes and arrays multiple levels deep in any combination, objects etc.) and it will return the complete contents to you. This makes object debugging much easier for me because often times the issue is in the fact that an attribute of object didn't get set correctly. With Dumper you can do this:
That will print what you already know since you created the structure, but what if you are getting back something that you are not sure of the contents on? This is where it comes in handy for both debugging and sometimes better understanding the contents in an object. Like so ( i am using code from an earlier post by artist ):
That will show you the complete data structure of a newly created object. I feel that the docs for Data::Dumper don't really make it clear how you would apply this module for someone that isn't doing full time development. Once you see how it is applied it will most likely become a very valuable debug utility for anyone working with hidden (dynamic) data structures, which should be most everyone I hope. In reply to Re: Data::Dumper in a nutshell?
by trs80
|
|