http://qs1969.pair.com?node_id=59888

Following the Huffman encoder posted here yesterday, here come the always useful Huffman decoder.

$/=$\;($l,$_)=unpack'sB*',<>;s/..//;r($&);$r=join'|',sort{$0{$b}cmp$0{ +$a}}keys %0;$_=substr$_,0,$l;s/$r/$0{$&}/g;sub r{@_=split//,pop;for$i(0,1){if($ +_[$i]){s /.{8}//s;$0{$p.$i}=pack'b8',$&}else{local$p=$p.$i;s/..//;r($&)}}}print

It is much shorter (229 bytes in Un*x), and as you will see, not much documented.