#!/usr/bin/perl -w use warnings; use strict; my %translate = ( "string a" => 1, "string b" => 2, "string c" => 3, true => 1, false => 0, ); my $match = "\Q" . join ("\E|\Q", keys %translate) . "\E"; while () { s/($match)/$translate{lc $1}/ige; print; } __DATA__ what is the best way to translate "TRUE" and "FALSE" to "1" or "0" respectively? or "string a", "String B", "String C" to "1-3" respectively.