Below is my attempt. Some assumptions are made the most important is that "" "seq_name" will be one line below "StrCatDone".
Also note I am a Perl newbie, so the code below is not of good quality. Any my logic is.
- Read the file into an array.
- Find the array index where you find: "StrCatDone" "1". Using the for(;;) loop.
- Modify the array element of the next index hence the ++$i.
- write the array back to the file.
use strict;
use warnings;
my $file = shift @ARGV;
open (my $fh1, $file) or die "Can't open file \"$file\", $!";
my @txt = <$fh1>;
close $fh1;
my $newtext = '"seq_name" "sequence.V6.0"';
my $i;
for ($i=0; $i <= $#txt; $i++) {
last if $txt[$i]=~ m/"StrCatDone" "1"/;
#print $txt[$i];
}
$txt[++$i]="$newtext\n";
open (my $fh2,">$file") or die "Can't open file \"$file\", $!";
print $fh2 @txt;