while () { if (( /^VAT/.../^DESCRIPTION/) && (!/^s*$/)) { next if /^VAT/; next if /^DESCRIPTION/; print; #these are the address lines print "\n" if (/\w+\d \d/); #the trick is to see #when address is done, eg a postal code } } __END__ prints: Miss Carol Hocker 177 Elm Road, Brighton East Sussex BN2 7HB Mr Whatever 177 Elm Road, Brighton East Sussex BN2 7HB __DATA__ Invoice Invoice No: C0331-2008 Invoice Date:27/02/2008 VAT No: 679 7113 03 Miss Carol Hocker 177 Elm Road, Brighton East Sussex BN2 7HB DESCRIPTION blah..blah Invoice No: C0331-2008 Invoice Date:27/02/2008 VAT No: 679 999 03 Mr Whatever 177 Elm Road, Brighton East Sussex BN2 7HB DESCRIPTION ...something here....