There are probably 50 or 60 ids.

Few enough!

The next line cannot match the one id. I should have posted a copy of that as well but basically 1 id will create 2 lines in the logfile and it is that second line I am trying to get at.

How 'bout the other question? Well, taking one assumption, one way to do what you're after may be along the lines of the following:

#!/usr/bin/perl use strict; use warnings; die "Usage: $0 <id_file> [<files>]\n" unless @ARGV; my %id_hit=map { substr($_, 0, 6) => 1 } do { my $idfile=shift; open my $fh, '<', $idfile or die "Can't open `$idfile': $!\n"; <$idfile>; }; while (<>) { if (/([A-Z]\d{5})/ and $id_hit{$1}) { defined(my $next=<>) or die "No 'next' line in `$ARGV' at line $.\n"; print $next; } } __END__

In reply to Re^5: Search a file with ids from another file by blazar
in thread Search a file with ids from another file by sigzero

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.