in reply to exchange words in text

Here is one way:
#!/usr/bin/perl my @l = split /(\n)/, <<ENDE; Guido bla1 ... Mike bla2 ... Klaus bla3 ... ENDE my %h = qw/ Guido Meyer Mike Smith Klaus Rothschild/; for (@l) { s/(\w+)/$h{$1} || $1/e; print } __OUTPUT__ Meyer bla1 ... Smith bla2 ... Rothschild bla3 ...
Boris