in reply to How do I search for every occurrence of strings within an array and display them?

Like the good Monks that came before me, I assume that your keywords are a) on one line, b) are separated by commas (maybe even with some space around them), and c) that you want a case-insensitive match. Especially for the latter, a regex is the way to go.

#!/usr/bin/perl -w use strict; open my $f, "keywords.txt" or die "keywords.txt: $!\n"; chomp(my $kw = join '|', split /\s*,\s*/, <$f>); close $f; my $re = qr/$kw/i; open my $s,"Skypelogs.txt" or die "Skypelogs: $!\n"; while (<$s>){ print if /$re/; } close $s;

--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf
  • Comment on Re: How do I search for every occurrence of strings within an array and display them?
  • Download Code