How can I change this code to insert lines if missing without deleting existing ones?
tie my @lines, 'Tie::File', $fn or die "could not tie file: $!";
for (my $i = 0; $i < @lines; $i++) {
if ($ln_title == 0) {
if ($i < $#lines and $lines[$i] =~ /(\s+TRACK \d\d .*)$/) {
$lines[$i+1] = ' TITLE ""';
}
}
}
untie @lines;