The -i.orig tells it to first rename the original input file to its old name followed by .orig, then run the script and put its output into a new file with the same name as the input file.
I suspect the code snippet you started off with assumed you were running under perl -p.