##
...
S AGT
...
R AGT
...
S AGT
...
R AGT
...
####
...
S AGT #1
...
S AGT #2
...
R AGT #1
...
R AGT #2
...
####
my @Srecs;
while( ) {
if( /^S AGT/ ) {
push @Srecs, $_;
}
elsif( /^R AGT/ ) {
die "R-record with no corresponding S-record" unless @Srec;
my @sRecBits = split ' ', shift @Srecs;
my @rRecBits = split ' ', $_;
## Calculate stuff
}
}
if( @Srecs) {
printf "There were %d unmatched S-records\n"; scalar @Srec;
}
## Other stuff