Hi Frank Assuming the file you're operating on is bar.txt, here's how I'd do it:
$ perl -i.bak -p -e 's/Debug/Error/g' bar.txt then you'll find the original file in bar.txt.bak $ diff bar.txt bar.txt.bak 1,3c1,3 < This is a Error < Please Error every replacement < with a Error --- > This is a Debug > Please Debug every replacement > with a Debug To find out more read: $ perldoc perlrun Hope that helps! Andrew On Thu, Jan 28, 2016 at 9:37 AM, 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 > -- Andrew Solomon Mentor@Geekuni http://geekuni.com/ http://www.linkedin.com/in/asolomon