Your code is beautifull, Benny. I am still looking what it exactly does. Could you elaborate on this line? I.E. what does the XOR do?
$a=a(Left($,~))+($^)*$a*($a>)