This is PerlMonks "Mobile"

Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  


in reply to How to repeat a line thrice by adding a digit into it

A variation on haukex's approach (assuming that guess about what you want is right):

>perl use warnings; use strict; # use following statement (or similar) in real program: # open my $fh, '<', 'actual_file_name' or die "opening: $!"; open my $fh, '<', \<<'EOD' or die "opening: $!"; # for demo only hello world foo_ bar foo foox baz foo_ foo_xyzzy boff EOD LINE: while (my $line = <$fh>) { if (my ($intro) = $line =~ m{ \A (foo) _ }xms) { print "$intro$_\n" for 1..3; next LINE; } print $line; } ^Z hello world foo1 foo2 foo3 bar foo foox baz foo_ foo1 foo2 foo3 boff


Give a man a fish:  <%-{-{-{-<