echo -e "One\nTwo\nother\mmore\nthan\nthat" | perl -ne 'BEGIN{chomp (@arr=);$x=join("|",@arr)};s /$x/FOOOO/; print "FILE:$_" ' file.txt