in reply to recode 2 strings into 1

No map required, but a hash sure helps:

use strict; use warnings; my @arg1 = split '', 'aaabbbccc'; my @arg2 = split '', 'abcabcabc'; my @result = split '', 'xyzrstmno'; my %rules; die "Mismatched lengths in input arrays" if @arg1 != @arg2 or @arg1 != @result; # Build the rules hash $rules{$arg1[$_]}{$arg2[$_]} = $result[$_] for 0 .. $#result; # Do da deed my @test1 = qw(a b c b b c a a); my @test2 = qw(a a b c c a b c); print "$test1[$_]:$test2[$_] = $rules{$test1[$_]}{$test2[$_]}\n" for 0 .. $#test1;

Prints:

a:a = x b:a = r c:b = n b:c = t b:c = t c:a = m a:b = y a:c = z

True laziness is hard work