use JSON; %HoA = ('foo' => [1,2,3], 'bar' => ['a','b','c']); print "plain:\n".JSON->new->encode(\%HoA)."\n"; print "pretty:\n".JSON->new->pretty->encode(\%HoA); #### plain: {"foo":[1,2,3],"bar":["a","b","c"]} pretty: { "foo" : [ 1, 2, 3 ], "bar" : [ "a", "b", "c" ] } #### { "foo" : [1,2,3], "bar" : ["a","b","c"] }