my $h = [[['t','o'],[['d','i'],'n']],[[['s','r'],['l','h']],['e',[['m',['f','b']] ,[[['k',['w','p']],['g','u']],'a']]]]]; my $m = '_001011110^_001_1000.000001.100111110111010110^000101111011100.111111010 1010b_001011110._001_1000^000001.11101001010110100.000101111011100d_00101111 0._001_1000^000001.111011100101010111111010.000101111011100.1111110101010b_1 11110110100^0101011^0001011110._0100111111001111100001111010001000^111011010 10110100.000101111011100b_0101011^0001011110^_1010111110110100^001111010._10 011100100111000010110100^1111001010111101001110^0001011110._11110011_1001.10 1001011101000d^....^^...^...^^..--._0001011110^_101000110010100^001111010.00 01011110._1001010101111110101000bb1111001011010101010c.1000001100100011111'; $m =~s!\s!!g; my %h=('^',' ','.',' ','b',"\n",'d',"\n",'c',',','e',',','-','-',); my $u; sub d { my($t,$d)=@_; if(ref($t)) { my $c=shift @{$d}; while($c !~ /^\d$/x && length $c) { ($c eq'_') ? $u=1 : print $h{$c}; $c = shift@{$d}; } return d($t->[$c],$d); } else { if ($u) { $u=0; print uc($t); } else { print $t; } return @{$d}; } } my @d = split//,$m; while(scalar @d) { @d = d($h,\@d); } print"\n";