Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!snorkelwacker!usc!ucsd!sdd.hp.com!zaphod.mps.ohio-state.edu!uwm.edu!ogicse!schaefer From: schaefer@ogicse.ogi.edu (Barton E. Schaefer) Newsgroups: comp.lang.perl Subject: Re: Novice Question: How is -e supposed to work? Message-ID: <11415@ogicse.ogi.edu> Date: 16 Aug 90 15:14:08 GMT References: <1990Aug16.070010.26529@morrow.stanford.edu> Organization: Oregon Graduate Institute (formerly OGC), Beaverton, OR Lines: 32 In article <1990Aug16.070010.26529@morrow.stanford.edu> 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/; } } and intimate that the result of running go on file bas will be a } changed file bas. } } however, when I try any of the following, the results are the same as } if only the -p switch were set. that is, the changes are printed to } the screen only, not to the original file. I'm curious what this has to do with the -e switch (as mentioned in the subject header). As speculation, I'll bet that you aren't really using a file named "go" containing the above two lines, but rather you are trying to use perl -pei.bak 's/foo/bar/;' < bas Even though that looks sensible to me, it isn't sensible to perl. (Why not, Larry? Is it that tough to parse?) When perl gets to the 'e' in "pei.bak" it quits reading from that argument and skips ahead to the expression. The "i.bak" is therefore never seen. Use perl -pi.bak -e 's/foo/bar/;' < bas and everything will be fine. -- Bart Schaefer schaefer@cse.ogi.edu