Thanks, that seems simple enough, it works and only takes about 8 seconds so should be good. I don't know if my interpretation of the suggestion is optimal but it got me to a solution, I just used an array as my data didn't need a keyed hash. The files are fairly basic text, less than 40,000 lines.
#!usr/bin/perl use warnings; use List::MoreUtils qw(any); open my $wave, '>', 'Wave' or die "Can't open $wave: $!"; open my $keywords, '<', 'Agents' or die "Can't open keywords: $!"; open my $search_file, '<', 'Definitions' or die "Can't open search f +ile: $!"; open my $schedule, '<', 'Schedule' or die "Can't open search file: $ +!"; @sched = <$schedule>; # read entire file into an array at the start my $keyword_or = join '|', map {chomp;qr/\Q$_\E/} <$keywords>; my $regex = qr|\b($keyword_or)\b|; while (<$search_file>) { while (/$regex/g) { $line = $_; chomp $line; if ( $line =~ /(SCRIPTNAME|DESCRIPTION)/ ) { next; } print $wave $line; if (any { $_ =~ $line } values @sched) { # check if line we're + on is also in the @sched array print $wave " | Yes!\n"; } else{ print $wave " | No!\n"; } } } $_->close for $wave, $keywords, $search_file, $schedule;

In reply to Re^2: nesting loops help? by shadowfox
in thread nesting loops help? by shadowfox

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.