use strict;
my $str = 'Time_in_seconds[1]Time_in_seconds
Time_in_seconds[123]Time_in_seconds
Time_in_seconds[*]Time_in_seconds
Time_in_seconds[1]Time_in_seconds
Time_in_seconds[2]Time_in_seconds
Time_in_seconds[3]Time_in_seconds';
my $regex = qr/(?:^Time_in_seconds\[\d+\]Time_in_seconds$(\R?))+/mp;
my $subst = 'My new line$1';
my $result = $str =~ s/$regex/$subst/rg;
print "The result of the substitution is' $result\n";
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html