#!/usr/bin/perl use strict; my $i = 1; while (<>) { if (/Startpoint/ ... /slack/ && $i < 2 ) { print $_; $i++; }