ouputsperl -MO=Deparse -pe 's/this/that/g;'
which you can save as e.g. this_that_replace.pl. To invoke this file, you need at least one inputfile as argument. This file (here: inputfile.txt) could contain the text 'This house is mine':LINE: while (defined($_ = readline ARGV)) { # readline: each call reads and returns the next line of a file until end-of-file is reached s/this/that/g;# replace 'this' by 'that' globally } continue {# this continue block on a while loop ensures that the print function is always called die "-p destination: $!\n" unless print $_; }
The modified text 'That house is mine' is now saved into the file outputfile.txt (thanks to the > operator).perl this_that_replace.pl inputfile.txt > outputfile.txt