Hi Frank, Invoke below command from your perl program to replace the string "Debug" to "Error":
sed -i -e '/Debug/ r filter.txt' -e s/Debug/Error/g filter_replaced.txt Above solution is provided as per my knowledge, please post if there is any other solutions for this. Thanks, Ram Murthy On Thu, Jan 28, 2016 at 8:29 PM, Logust Yu via beginners <beginners@perl.org > wrote: > You can probably achieve this easily with 'sed' on bash. > > On 28 Jan 2016, at 09:37, Frank Larry <frankylarry2...@gmail.com> wrote: > > Hi Team, > > could you please let me? i have a file which contains "Debug", i would > like to replace debug to "Error", when i ran the below program the out > showing Error message but how to save the output with new changes. Could > you please tell me how to fix it? > > open(FILE, "<filter.txt") or die "Can’t open $!\n"; > > while($line = <FILE>){ > print "Before substituting: ", $line ,"\n"; > $line =~ s/Debug/Error/g; > print "After substituting : ", $line , "\n"; > } > > close(FILE); > > > -Franky > >