From: "Mark Wagner" <[EMAIL PROTECTED]> > I've got a script I'm using to search through a list of Wikipedia > article titles to find ones that match certain patterns. > > As-written, if you run it and supply '.*target.*' on standard input, > it will process my test file in 125 seconds. Make any of the changes > mentioned in the comments, and the time needed will drop to 1.8 > seconds. Why the difference? Particularly interesting is that it > seems to matter where the regex pattern came from: if it's from > standard input, testing is slow; if it's assigned in the script, > testing is fast.
Have a look at the qr operator. The thing is that if you use $something =~ /^$regex$/; in a loop, Perl has to copile the regular expression for each iteration. Because it can't know whether the $regex variable is still the same or not. HTH, Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/