in reply to Remove line and modify another

Here's an SSCCE for your point 1:

use strict; use warnings; use Test::More tests => 1; my $in = 'foo .024. 3# bar'; my $want = 'foo bar'; my $try = $in; $try =~ s/\.024\. 3# \n//; is ($try, $want);

Now it's up to you to do the same for point 2. Can you?