in reply to Re: Searching for strings specified via user input
in thread Searching for strings specified via user input

Thank you! I have taken your example and adapted it to my own purposes. I was wondering how I could go about using a space as the delimiter for each search string i.e. in my original code I would specify each substring via: my @pats=qw( GATCR GGCC ); However I now need the user to input each substring with a space in between each and for the script to treat each one as a separate search to carry out. Thanks again!

Replies are listed 'Best First'.
Re^3: Searching for strings specified via user input
by AppleFritter (Vicar) on May 01, 2014 at 16:13 UTC

    You're welcome! Just to avoid unnecessary confusion, when the user enters multiple strings, are you interested only in matches that match all these, or all matches that match any of these?

    Either way you'd want to split the user-supplied search string along whitespace. I'd do that in your hypothetical search_for_pattern routine; in the latter case, you could also do it after the user supplied a search string, and then use a loop to call search_for_pattern for each individual search term, but this could be inefficient if you have a lot of data to deal with.