Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!samsung!emory!gatech!mcnc!uvaarpa!mmdf From: worley@compass.com (Dale Worley) Newsgroups: comp.lang.perl Subject: Why is this so slow? Message-ID: <1990Dec7.212127.8161@uvaarpa.Virginia.EDU> Date: 7 Dec 90 21:21:27 GMT Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System) Reply-To: worley@compass.com Organization: The Internet Lines: 23 From: merlyn@iwarp.intel.com (Randal Schwartz) $lines_per_page = 66; $max_pages = 100; # you forgot this while (<>) { $lineno++; $pageno++, $lineno = 0 if /\f/ || ($lineno >= $lines_per_page); die "Aborted at page $pageno\n" if $pageno >= $max_pages; print; } Well, to start with, if there are two form-feeds in one line, $pageno will only get incremented by 1. I may be wrong, but to find out the number of times a regexp matches a string, you have to write an explicit loop. Dale Worley Compass, Inc. worley@compass.com -- In _EE_Times_, 16 October 1989, Intel VP David House says: "Bill Gates [software maker Microsoft's chairman] says no matter how much more power we can supply, he'll develop some really exciting software that will bring the machine to its knees."