Ok, this isn't that tricky if you disect the command line switches one at a time:
-eThis means essentially "execute the following code". As you can see, in this particular case, the following code is nothing at all; zilch.
-pThis means wrap the -e code in the following loop:
while( <> ) { # -e code goes here (nothing, in this case) print $_; }
Now for the -i: That means do an in-place edit. Whatever characters immediately follow -i will be appended to the input file's name for the purpose of creating a backup file. Often you'll see -i.bak which means take file foo and create a backup named foo.bak. Well, in your case, instead of .bak you're using ~, so it creates a backup named foo~.
Now put it all together:
I hope this helps, but if it doesn't, see perlrun for more detail. Also (shameless plug), I wrote a node awhile back that went into greater detail on the subject of learning how to compose Perl one liners. The node is here: Re: One Liners. I think you'll find it to be a pretty easy introduction to Perl's command line switches and Perl one-liners. Good luck!
Dave
In reply to Re: perl's command line snippet which I read from a perl article ( perl tutrous )
by davido
in thread perl's command line snippet which I read from a perl article ( perl tutrous )
by jesuashok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |