Otherwise, you should really read the documentation, but these are quick answers to your question. The command line switches say:perl -i.bak -p -e "s/gary/harry/g;" file.txt
Inline editing, i.e. the file itself is modified (but, yes, there is some file renaming behind the scene);-i
Assumes an input loop around the script to read all lines of the original file and print back the modified lines.-p
the text coming between the quotes after this switch is to be taken as the Perl script to be executed (the more common usage, without the -e switch, is to put there name of the file containing the script.-e
s/source/target/ is the substitution operator. It replaces source with target. In this specific case, the substitution is applied to the string contained in the default $_ variable, which contains successively each line of the input file. The g modifier says that this substitution should be made as many times as possible (i.e. for all occurrences of source in the current string).
This was just a very quick answer to your questions (too short to be entirely accurate, but at least you should get the idea), there would much more to say, but go for the documentation you have been pointed to by other monks.In reply to Re: Text not being replaced in file via Windows CLI ...
by Laurent_R
in thread Text not being replaced in file via Windows CLI ...
by perlynoob
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |