This code looks suspiciously like the examples for Huffman Encoding in "Mastering Algorithms with Perl". I'm not sure what you think it should do, but the ',' in there is not valid syntax and should be replaced with a '?'. You've also got a $cur_code where you want a $cur_node. For your typo convenience, all of the examples in the book are available in .tar.gz or .zip format from O'Reilly's web site
We really need to see what you constructed for the get_bit() and put_stream() routines and how you constructed your hash tree.
If you still don't understand how this works after you get the typos fixed, I'm sure we can discuss how this walks down a tree looking for nodes, checking whether a node contains a value or a link/reference to another node, and outputting any values found or following the link/reference to the next node depending on what it finds in the current node. :)