I have an input file data
int abc;
.abc(pqr)
.abc(abc_p)
I want the output data asint abc_1;
int abc_2;
.abc(pqr)
.abc_1(abc_p_1)
.abc_2(abc_p_2)
Can you please point me where is the mistake in the code.use strict; use warnings; my $data = <<IN; int abc; .abc(pqr) .abc(abc_p) IN my $a = qr{ [ .(] }xms; my $b = qr{ abc_p | abc }xms; open my $fh, '<', \$data; while (my $line = <$fh>) { if ($line =~ m{ $a $b }xms) { for my $i (1 .. 2) { (my $c = $line) =~ s{ ($a $b) }{${1}_$i}xmsg; print $c; } } else { print $line; } }
In reply to Not getting proper output value by suvendra123
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |