in reply to and or statement

Your question is very unclear. It's hard to tell what you want to obtain. Maybe

my @matches = ( $element =~ /(WEED)/, $element =~ /(DIAL)/, $element =~ /(PIES)/, $element =~ /(KILLD)/, ); if (@matches) { ... }

The above can be shortened by using map as a topicaliser.

if (my @matches = map { /(WEED)/, /(DIAL)/, /(PIES)/, /(KILLD)/ } $ele +ment) { ... }

Update: If you don't mind one of the strings appearing twice if it appears twice in $element, you can use

if (my @matches = $element =~ /(WEED|DIAL|PIES|KILLD)/g) { ... }

Replies are listed 'Best First'.
Re^2: and or statement
by ww (Archbishop) on Nov 08, 2011 at 00:36 UTC
    1. Agree heartily with previous respondents, ikegami and AnomalousMonk: Your intent is unclear.
    2. Your sample data (which sometimes makes our crystal balls more useful) is missing.
    3. ...and, further re ikegami's solution:

    If your $element = "WEED BECAUSE PIPES KILLD THE PIES WITHOUT DIAL. PIPES ARE NOT GOOD FOR PIES.";

    his multi-regex solution will tolerate use of /g, and -- with the addition of this code,

    if (@matches) { for ( @matches ) { say $_; } }

    -- will produce this output:

    WEED DIAL PIES PIES KILLD
      I like it yes that will work nicely. Sorry it was just a module of a larger piece to find motifs in a fasta formatted data set containing multiple fasta sequences from a file which I input as asked. I parsed the fasta sequence w/ a foreach loop and after each is parsed it runs this (match) part of the loop on the sequence data to discover whether the sequence contains the motifs or patterns. I only need one match per pattern, but have multiple patterns and require ID of each match case (ie only return pies once despite the number of occurrences; if pies and weed is found multiple times return both, but only once to indicate presence.