Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uwm.edu!psuvax1!news From: flee@cs.psu.edu (Felix Lee) Newsgroups: comp.lang.perl Subject: Re: Sluggish patterns. Message-ID: Date: 5 Apr 91 07:31:09 GMT References: <1991Apr1.181801.16850@uvaarpa.Virginia.EDU> Sender: news@cs.psu.edu (Usenet) Organization: Penn State Computer Science Lines: 25 Nntp-Posting-Host: dictionopolis.cs.psu.edu > eval "sub cookie { &eat() if /$cookie/o; }"; > eval "sub monster { &run() if /$monster/o; }"; > while (! $done) { > &begin(); > &cookie; > &monster; > &end(); > } Okay. Now how do you make it recursive? sub ctw { local($cookie, $monster) = @_; while (! $done) { &eat() if /$cookie/; &run() if /$monster/; } } $cookie and $monster change infrequently, but they may change in either &eat or &run. Either &eat or &run may call &ctw recursively with random parameters. It doesn't look very hard to change Perl so it does a cheap string compare before it recompiles run-time patterns. -- Felix Lee flee@cs.psu.edu