%_=(62 => 20, 38 => 1, 35 => 50, 33 => 2, 60 => 10, 37 => 5); # Match each chunk of optional characters in a specific order # Look up the ASCII values of each char in the chunk in the hash # Add the hash values plus a starting value of 30 # Replace the chunk with the character whose ASCII you just added up # (Pattern modified to add \s* so that chunks could be # formatted prettily) s:#*>*<*%*!*&*\n*\s*: $;=30; $;+=$_{+ord} for split'',$&; chr$; :eg for $_=q:>>!! #><%&& >>>>% >><<<<%& ! #<%! #>< >>><<& #<<>>%%& >><<%%%%&&&& ! >>< #>& >>><>>%%%&&& ! ><<<<<&&&& >><<%! >><%%%&&&& #>%&& >>><& >>>>&&&&:; print;