Find multiple strings and replace single string

Hi,

following Perl code i used for finding multiple strings and replace with single string.

code:

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


foreach $fileName (@files) {
  print "$fileName\n";

  my $searchStr = ',rdata\)' | ',,rdata\)' | ', ,rdata\)';
  my $replaceStr = ".read(status,rdata)";

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

i am not seeing ",rdata" , ",,rdata" and ", ,rdata" replaced with ".read(status,rdata)"

I used OR operator.

Rgds,
Ravi

Pls refer the thread that you posted last week.

Also you can use a regex instead of OR and saving to variables..

$line=~ s/,\s?,?rdata\)/\.read\(status,rdata\)/g;

thx rajamadhavan,

Is this following code is correct:

Code:

$line=~ s/,\s?,?rdata\)|,,?rdata\)|,?rdata\)/\.read\(status,rdata\)/g;

ravi.