my %res; %res = @_ =map { $_ => do { my $re; $re .= $translations{$_} for split //; $re; } if !$res{$_}; } @words;