How can I print the contents of a hash in Perl?

前端 未结 11 1563
借酒劲吻你
借酒劲吻你 2020-12-22 15:52

I keep printing my hash as # of buckets / # allocated. How do I print the contents of my hash?

Without using a while loop would be most preferable (for

11条回答
  •  北荒
    北荒 (楼主)
    2020-12-22 16:29

    If you want to be pedantic and keep it to one line (without use statements and shebang), then I'll sort of piggy back off of tetromino's answer and suggest:

    print Dumper( { 'abc' => 123, 'def' => [4,5,6] } );
    

    Not doing anything special other than using the anonymous hash to skip the temp variable ;)

提交回复
热议问题