in reply to
Is it possible to insert a record after line 5 that appears on line 10?
Here's something to help you get started. Notice in the first pass, I grabbed the 3rd record. And in the second pass, I printed the 2nd record.
#!/usr/bin/perl
use strict;
my $data_pos = tell DATA;
my $record;
while (my $line = <DATA>) {
chomp( $line );
$record = $line if ( $line =~ /^:16R:USECU/ );
}
seek DATA, $data_pos, 0;
while (my $line = <DATA>) {
chomp( $line );
print "$line\n" if ( $record && $line =~/^:16S:GENL/ );
}
__DATA__
:16S:LINK
:16S:GENL
:16R:USECU