my $old = 'hat|coat|shoe'; my %new = ( cap => 'hat', jacket => 'coat', shoe => 'boot', ); for my $word ( @words ) { $word =~ tr/[A-Za-z]/[M-ZA-Lm-za-l]/; # decode ROT13 $word =~ s/($old)/$new{$1}/ei; # convert cheap clothes into expensive ones }