table = {'pl'=>'Perl', 'rb'=>'Ruby'}
pattern = Regexp.compile(table.keys.join('|'))
puts("pl rb pl rb".gsub(pattern){table[$&]})