in reply to Matching numeric digits in strings
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
|
|---|