#!/usr/bin/perl use warnings; use strict; while () { if (/^\s*\(\d+\).+Significant Accounting Policies/) { print; #this is the SAP heading line print while (defined ($_ = ) and $_ !~ /^\s*\(\d+\)/); } } __DATA__