SPUG: Searching for multiple strings

Colin Meyer cmeyer at helvella.org
Thu Jul 6 14:50:35 CDT 2000


On Thu, Jul 06, 2000 at 09:31:31AM -0700, Andy Jacobs wrote:
> I've written a program that searches a lot of text sources for multiple
> search strings (among other things).  The search strings are read as input
> from a file at run time (supplied by the user).  The program builds a table
> of which search strings appear in which sources.  Each source string may
> contain many search strings (perhaps overlapping), and each search string
> may appear in multiple source strings.

Have a look at perlfaq6, specifically the question, 'How do I efficiently match
many regular expressions at once?'.  

Can you define your problem more precisely?  If you only need to know whether 
or not a line matched any of the patterns vs. specifically which patterns it
matched, then you can bail out of the loop on the first match to save much 


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
     Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For full traffic, use spug-list for LIST ; otherwise use spug-list-digest

More information about the spug-list mailing list