A sublime example for the use of the -i switch when using perl from the command line. See. perlrun for info on this marvellous switch (best used in conjunction with -p and -e).
HTH
I use this one all the time. A quick example of broquaint's suggested technique (from the command line), to replace all capitalization permutations of the word 'perl' to 'Perl' in file perl.pl, and store the original in perl.pl.bak: