$fh = <>; #first line of input is FT chomp $fh; #get rid of newlines $/ = "\nBH"; #set Input record seperator to newline followed by BH while (<>) { #loop through each chunk @lines = split /\n/,$_; #split chunk into lines chomp @lines; #get rid of newlines; $bh = shift @lines; #BH is first line. $ft = pop @lines; #on last iteration FT will be last line, otherwi +se the lastline is a bare BH ($bh =~ /^BH/) || ($bh .= "BH" . $bh"); #if $bh doesn't start wit +h BH then put it back. foreach $trans (@lines) { process($trans, $bh); #each remaining line is a single transac +tion line } }
In reply to Re: Parse File Containing Multiple Batches With Correlating Detail Records
by anithri
in thread Parse File Containing Multiple Batches With Correlating Detail Records
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |