use strict; use warnings; my $inData = <) { # if ($line =~ if( my ($intro) = $line =~ /([.(]?abc)/g){ print "${intro}_$_;\n" for 1 .. 2; } } close $in_fh1;