Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!decwrl!shelby!morrow.stanford.edu!lindy.stanford.edu!whenry From: whenry@lindy.stanford.edu (homo obsolescensis) Newsgroups: comp.lang.perl Subject: Re: Novice Question: How is -e supposed to work? Message-ID: <1990Aug16.172303.12982@morrow.stanford.edu> Date: 16 Aug 90 17:23:03 GMT References: <1990Aug16.070010.26529@morrow.stanford.edu> <11415@ogicse.ogi.edu> Sender: news@morrow.stanford.edu (USENET News System) Organization: Stanford University Libraries Lines: 36 In article <> schaefer@ogicse.ogi.edu (Barton E. Schaefer) writes: >In article <> whenry@lindy.stanford.edu (homo obsolescensis) writes: >} >} I am having trouble using the -e switch. the man >} pages give the following example: (lets call this file "go") >} >} #!/usr/bin/perl -pi.bak >} s/foo/bar/; >} >I'm curious what this has to do with the -e switch (as mentioned in >the subject header). Urgh, am I embarassed. my question is about -i, not -e. just a typo, caused by lack of sleep. the above fragment is given in the man pages as an equivalent to perl -p -i.bak -e "s/foo/bar/;" ... Mr. Schaefer suggests > perl -pi.bak -e 's/foo/bar/;' < bas > >and everything will be fine. This does indeed work as far as -e is concerned (s/foo/bar is done) but not as far as -i (or, more likely I dont understand -i). shouldnt your fragment result in bas being overwritten with the changed text? and the original bas renamed to bas.bak? when I do what you suggest bas is just written to the screen (with, of course, the changed text). the man pages give yet a third "equivalent" example (much longer, so I wont quote it), in which bas is indeed overwritten (and a .bak made) (Im really sorry about the confusion caused by my typo and much appreciate your answer, which I learned something useful anyway). Walter Henry