Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Perl Neophyte Needs Help Message-ID: <8512@jpl-devvax.JPL.NASA.GOV> Date: 27 Jun 90 17:05:35 GMT References: <8504@jpl-devvax.JPL.NASA.GOV> <1990Jun27.101219.11357@comp.vuw.ac.nz> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 21 In article <1990Jun27.101219.11357@comp.vuw.ac.nz> Andrew.Vignaux@comp.vuw.ac.nz (Andrew Vignaux) writes: : I think the only time *I* every really want to do this is for building : the regexp test(s) based on the script arguments i.e. a grep-like : script (just like this example). Does/could perl notice that $pattern : is invariant in the original program and arrange to compile the regexp : only once? To recognize that invariance of a variable over a loop is not trivial. That's why I put in the o modifier. The basic problem is that the o doesn't have any effect until after the optimizer is run, since the pattern is not compiled until the first time the loop is executed. The solution will be to make the o modifier set things up so that the pattern can be optimized at that point to run as fast as if the pattern were known at compile time. I think this is doable. Then you won't have to use the eval trick on loops to squeeze that last bit of efficiency out. I won't guarantee it in the next patch, however. Larry