B
banker123
I am trying to while through a file extract the batch and seq number
which corresponds to each invoice number (35246,35247) and amount. My
code extracts the second invoice number, and creates a one-to-one
relationship. I would like a one to many, one batch and seq and many
invoices. Please help.
DATA
Batch:00123456 Seq:0001 35246 1.00
35247 10.00
while ( <DATA> ) {
if (/\s\sBatch/ ) {
$batch = substr($_,9,8);
$seq = substr($_,22,4);
}
elsif (/\s{8}\d{5}/) {
$invoice = substr($_,32,14);
print "$batch $seq $invoice\n";
}
}
which corresponds to each invoice number (35246,35247) and amount. My
code extracts the second invoice number, and creates a one-to-one
relationship. I would like a one to many, one batch and seq and many
invoices. Please help.
DATA
Batch:00123456 Seq:0001 35246 1.00
35247 10.00
while ( <DATA> ) {
if (/\s\sBatch/ ) {
$batch = substr($_,9,8);
$seq = substr($_,22,4);
}
elsif (/\s{8}\d{5}/) {
$invoice = substr($_,32,14);
print "$batch $seq $invoice\n";
}
}