use strict; my $wordOne = 'longwordOne'; my $wordTwo = 'anotherLongWord'; my $wordThree = 'thirdLongHere'; while () { next if ($_ =~ /(?:$wordOne|$wordTwo|$wordThree)/gi); print ; } exit; __DATA__ blah blah longwordOne blah blow blow blee anotherLongWord glgl thirdLongHere fddsf ds sdfs fs fsd fggh hg longwordOne sdasd #### blow blow fddsf ds sdfs fs fsd sdasd #### next if /$wordOne|$wordTwo|$wordThree/i;