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. :)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||