#!/usr/bin/perl -w use strict; use warnings; open(FH, "Wachterpdf2txt.txt") or die "We have a problem: $!"; my @invoiceSearch = ("phone", "hunt", "dial", "tone", "static", "18d", "system", "voice", "numbers", "voicemail", "MLX201", "programming", "extension", "processor", "block", "mls", "programmed", "rollover", "extension", "partner", "crosstalk", "merlin", "ringing"); my $regexStr="^static\\s+\\w+\\s+(" . (join "|",map quotemeta,@invoiceSearch) . ")\\W.*"; print "$regexStr\n\n"; my $regexStr_rr = qr{$regexStr}i; # or "cloister" the 'i' in $regexStr while() { chomp; my ( $hit ) = $_ =~ /$regexStr_rr/; if ($hit) { print "Beatle method \"$hit\" found on this line: $_\n"; } else { print "No Beatle method found on this line: $_\n"; } }