Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!lll-winken!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Globbing Message-ID: <7234@jpl-devvax.JPL.NASA.GOV> Date: 2 Mar 90 01:12:44 GMT References: <15209@bfmny0.UU.NET> <100306@convex.convex.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 35 In article <100306@convex.convex.com> tchrist@convex.COM (Tom Christiansen) writes: : Also, I'd love to use /o on a couple things here, but that would : mean only being able to call the function once. Any way to invalidate the : /o thing? I would like to do a grep(/$expr/o, @args) where the $expr is : only compiled once per new grep but not at every internal iteration of : grep, and I don't think it's currently feasible. That way you could do: : : for $expr (@list) { : for $item (@other_list) { : &foo if $item =~ /$expr/o; : } : } : : and have the $expr compiled only once per iteration of the outer loop. You can do it like this: for $expr (@list) { eval "#$expr" . ' for $item (@other_list) { &foo if $item =~ /$expr/o; } '; } The purpose of the #$expr is to force recompilation of the otherwise identical (and hence not recompiled) string. This may or may not save you time, depending on how long @other_list is. There is considerable overhead in recompiling each time through the outer loop. I could conceivable reset //o at the same time as I reset ?? searches. Larry