in reply to char substitution without regexes

Awww, jwkrahn beat me to it. Here's one that doesn't use tr/// either:
my %complement = ( a t g c ); %complement = ( %complement, reverse %complement ); print map $complement{$_}, reverse split //, $chain;

%hash and $string are awful names, so I changed them.

Replies are listed 'Best First'.
Re^2: char substitution without regexes
by jwkrahn (Abbot) on Sep 30, 2010 at 17:59 UTC

    Yes, but, that uses a regex and the OP said "without regexes".

      It passes a pattern, but it's actually special-cased not to use the regex engine.

      Ok, so I did it without thinking.

      print map $complement{$_}, reverse unpack '(a)*', $chain;

        Now you've got it!   :-)

        By the way, which do you think would be more efficient, reversing the list, or reversing the string first?