分类: Python/Ruby
2011-10-24 09:11:53
Evaluates its expression in list context and dumps out the result in a pretty-printed fashion. Nested data structures are printed out recursively, unlike the real function in Perl. When dumping hashes, you'll probably prefer 'x \%h' rather than 'x %h'. See if you'd like to do this yourself.
The output format is governed by multiple options described under .
DB<1> s
DB<2> x \%hash
0 HASH(0x9daf80c)
'gilligan.crew.hut' => HASH(0x9e46294)
'all' => 4721
'lovey.howell.hut' => 4721
'thurston.howell.hut' => HASH(0x9e46214)
'all' => 4046
'lovey.howell.hut' => 4046
When we give x a hash reference, it dumps the entire contents of the hash, showing the key/value pairs. If any of the values are also hash references, it dumps those as well, recursively. What we'll see is that the %hash hash has a single key of gilligan.crew.hut, whose corresponding value is another hash reference. The referenced hash contains a two keys of all , with a value of 1250 and lovey.howell.hut value of 4721.