#!C:/Activeperl/bin/perl.exe use strict; use warnings; my @final_array=qw/test1 test2 fred/; #open(DOC,'sample_testing'); while(defined($_=)){ #$_.=; <- why are you appening? foreach my $value (@final_array) { s/$value/pagingRAC/g; } print $_; } __DATA__ this is a test this line contains test1 and test2 fred bassett is a dog but I can't spell his name. #### this is a test this line contains pagingRAC and pagingRAC pagingRAC bassett is a dog but I can't spell his name.