Find and replace, perl code

Hi,

Can somebody tell whats wrong with "find and replace perl code".

I wanted to find "\n".write(status,data" and replace with "\n",data" in multipls files.

#!/usr/bin/perl
my @files = <*.c>;


foreach $fileName (@files) {
  print "$fileName\n";
 
  my $searchStr0 = '\n".write(status,data';
  my $replaceStr0 = '\n",data';

  open(FILE,$fileName) || die("Cannot Open File");
  my(@fcont) = <FILE>;
  close FILE;
  
  open(FOUT,">$fileName") || die("Cannot Open File");
  foreach $line (@fcont) {
      $line =~ s/$searchStr0/$replaceStr0/g;
        print FOUT $line;
  }
  close FOUT;
}

thx in advance

Rgds,
Ravi

Post a block of sample data from one file with a couple of lines before and after the lines where the replacement should occur.

Hi,

I want to find and replace following highlighted portion

$display("Register write value\n".write(status,data));

with following.

$display("Register write value\n",data);

Rgds,
Ravi.

$
$ cat file1.c
file1.c - line 1
file1.c - line 2
$display("Register write value\n".write(status,data));
file1.c - line 4
file1.c - line 5
$
$ perl -plne 's/\.write\(status,data\)/,data/' file1.c
file1.c - line 1
file1.c - line 2
$display("Register write value\n",data);
file1.c - line 4
file1.c - line 5
$

thx u durden_tyler.

its working.

Rgds,
Ravi.