s| .* # greedily match (\w) # match first letter, and store into $1 .* # greedily match (\w) # match last letter, and store into $2 .*\n # eat up remainder of line | # this expression maps the relevant character to its Base4 digit from # the %_ hash. The $- is used as a line counter (it defaults to 0). When # the DNA strands flip positions, this continues decoding on the correct # strand (see physi's comment for a visual representation of this) $_{$-++ / 9 % 2 ? $2:$ 1} |gex;