in reply to how to print key and value of hash as it is

print $b = $a;

It isn't immediately obvious to me what you expect this statement to do. What it actually does is to extract the value from $a, store it in $b and then print it. What did you intend?

Other things you might be interested to know:

It might be better all round for you to provide your expected output because it's not at all clear to me what your code is intended to do.