What does Perl's -p command-line switch do?
perl
Solution
- `-p`: assume '`while (<>) { ... }`' loop around program and print each processed line too.
- `-i.bak`: change the input file (`filename`) inplace and create the file `filename.bak` as backup.
- `s in s/`: to mark substitution
- `g` - make the substitution globally..that is don't stop after first replacement.
Problem
``` perl -p -i.bak -e 's/search_str/replace_str/g' filename ``` What do `-p`, `-i.bak` `s/` and `/g` mean?