#!/usr/bin/perl use 5.014; # 984660 my $stdout; # I hate this var name; too confuse-able... but it's your given my (@string) = ; for $_(@string) { $stdout .= $_; } if ( $stdout =~ / (?:OVERVIEW) # find start point (and KISS!) (.+) # match pretty much anything (?=AFFECTED\sPRODUCTS) # up to AFFECTED PRODUCTS -- USING A LOOKAHEAD, (?=...) /xs # extended notation, single line mode (ie, . matches newlines) ) # close the conditional - not part of regex { print "$1\n"; } __DATA__ ...