G'day kulua,
Welcome to the Monastery.
"I am new to perl."
As a first step, please read "perlintro: Perl introduction for beginners".
It's not particularly long and will provide you with a basic understanding of the language.
It's also peppered with links to more detailed information and advanced topics: use those as the need arises.
Next, bookmark the "Perl Online Documentation".
Initially, I'd suggest just familiarising yourself with the basic sections:
it's a reference work; there's no expectation that you should read it in its entirety.
"I search in the internet for perl code . ... What should be the modified code."
Well, I don't know what search criteria you used, but you've posted what looks like some variety of Bourne shell code.
Here's some fully-functional Perl code that achieves your stated objectives using the input data you provided:
#!/usr/bin/env perl
use strict;
use warnings;
use autodie;
my $in_file = 'pm_11132903_input.txt';
my $out_file = 'pm_11132903_output.txt';
my $format = ".%s(%s),\n";
{
open my $in_fh, '<', $in_file;
open my $out_fh, '>', $out_file;
while (<$in_fh>) {
if (/^(rist_top_\w+)/) {
printf $out_fh $format, ($1) x 2;
}
else {
print $out_fh $_;
}
}
}
# Just for testing and demonstration
print "*** INPUT: $in_file ***\n";
system cat => $in_file;
print "*** OUTPUT: $out_file ***\n";
system cat => $out_file;
Output:
*** INPUT: pm_11132903_input.txt ***
module abc(
rist_top_tck,
rist_top_tdi,
rist_top_tdo,
*** OUTPUT: pm_11132903_output.txt ***
module abc(
.rist_top_tck(rist_top_tck),
.rist_top_tdi(rist_top_tdi),
.rist_top_tdo(rist_top_tdo),
|