#!/usr/bin/perl -w my %lookup = (); # Construct the lookup table while () { chomp; my @list = split; # assuming space separated $lookup{$list[0]} = $list[1]; # search => replace } # Go through the search file and check for lookup strings using # the hash and replace it with the hash-value while () { for my $k (keys %lookup) { s/$k/$lookup{$k}/g; } print; }