in reply to Multi-line Regex Performance
You could avoid the regex engine entirely, and also the risk of swapping should your file(s) get bigger, by setting $/ = "##"; and reading the file one multi-line record at a time:
#! perl -slw use strict; while( $_ = do{ local $/ = "##REPORT"; <DATA> } ) { next if $. == 1; ##skip first empty record. print substr $_, 11, 10; } __DATA__ ##REPORT 01 A ARCUR1GMU# 00112106 F N ARCUR1 ARCU +R1 P 02 AR CURRENCY CONVERSION CONTROL - (BY PTR) + N 03 FROM FVENDAP1 04 CODE: 10 RECORDING & REPORTING GMU / NON-WHQ ONLY RE +PORTS 07 00112704 00200103 11 R 3 RD.RDSMODEL C 00 +08 0001 12 A 0007 000 000 00 +0 000 13 VDLTP02 14 S N VDLTB02 ##REPORT 01 A ARCUR10000 00112106 F N ARCUR1 ARCU +R1 P 02 AR CURRENCY CONVERSION CONTROL - (BY PTR) + N 07 00112704 00200103 11 R 3 RD.RDSMODEL C 00 +08 0001 12 A 0007 000 000 00 +0 000 13 VDLTP02 14 S N VDLTB02
This PBP-rated -4 code example produces
P:\test>junk2 ARCUR1GMU# ARCUR10000
And should run considerably more quickly.
|
|---|