I think it can probably be a lot simpler than what you've currently got. And the simpler it is, the easier it is to debug and maintain.
# read required ids into an array my @reqids = <REQIDS_FILE>; chomp @reqids; # build regex containing all required ids my $re = join '|', map { "\Q$_\E" } @reqids; $re = qr/$re/; # Process infile a line at a time looking for matches while (<INFILE>) { if (/$re/) { print "Matched - $_"; if (/SELECT/) { for (1 .. 3) { print scalar <IN_FILE>; } } } }
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: Matching numeric digits in strings
by davorg
in thread Matching numeric digits in strings
by flemi_p
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |