in reply to comparing two arrays and displaying scalar matches

You want to check all patterns against all lines. That's two loops.

  1. For every pattern,
    1. For every line,
      1. If the line matches the pattern,
        1. Print the line.

To avoid printing the same line more than once, you could join the patterns into one. That moves one of the loops into the regex engine.

  1. my $pattern = join '|', @patterns;
  2. For every line,
    1. If the line matches the combined pattern,
      1. Print the line.