in reply to To repeat each word in a line
repeats=2 while read line; do yes $line|head --lines=$repeats; done < infile > o +utfile
This is not Perl code. It looks like some kind of shell script.
Here's another approach to the problem that uses a script rather than a one-liner. I'm assuming you know how to handle file input/output, so this is just an example of a regex. This code needs Perl version 5.10 or greater; if you have an earlier version of Perl, a fix can be supplied.
Win8 Strawberry 5.30.3.1 (64) Sun 05/23/2021 2:40:51 C:\@Work\Perl\monks >perl use 5.010; # need regex extended pattern \K use strict; use warnings; use autodie; my $data = <<'EOD'; module abc( rist_top_tck, rist_top_tdi, rist_top_tdo, EOD open my $fh, '<', \$data; while (my $line = <$fh>) { $line =~ s{ \A (\w+) \K (?= ,) }{($1)}xms; print $line; } close $fh; ^Z module abc( rist_top_tck(rist_top_tck), rist_top_tdi(rist_top_tdi), rist_top_tdo(rist_top_tdo),
Give a man a fish: <%-{-{-{-<
|
|---|