my @array = split('\n',$output); if ( grep { $_ =~ /$PatchPath/ } @array ) { print "Match found\n"; }