hi Gurus,

I have a problem to replace strings of file thru perl script.


Here is the problem in detail...


I have a text file  some thing like this..


PROJ_FOLER=C:\Proj
PROJ_LOGS=C:\PROJ\LOGS


I have same line in config file some thing like this.


PROJ_FOLDER=D:\Proj
PROJ_LOGS=D:\PROJ\LOGS.


Now i read variables from text file split them like this

my ($key,$val)= $line =~ /^(\w+)=(.+)$/mg ;

and place both in a varaible $rep_line="$key=$val";

and search in the config file with $key (which has PROJ_FOLDER) and get to
the result to $line.

Now i will replace $line with $rep_line using

perl -i -p -e 's/$line/$rep_line/g'  $file;

Here is the code i have written...

BEGIN________

#!/usr/bin/perl
my $config_path="E:/MessageArchive/WorkArea/config.txt";
$file="E:/temp/FT/config/FTMessageArchive.configd";
open FH, "$config_path";

 while ($line=<FH>)
     {


     my ($key,$val)= $line =~ /^(\w+)=(.+)$/mg ;
     $repline="$key=$val";
     open $LOGFILE, '<', $file;
                       while ($line1 = <$LOGFILE> )
        {
          if ($line1 =~ m/$key/){ system("perl -i.bak -p -e
's/$line1/$repline/g' $file");close $LOGFILE;last;}

       }
                                 }
  close(FH);
END _____________

if i run the script I am getting the following errror..


Can't find string terminator "'" anywhere before EOF at -e line 1.
Can't find string terminator "'" anywhere before EOF at -e line 1.
Can't find string terminator "'" anywhere before EOF at -e line 1.
Can't find string terminator "'" anywhere before EOF at -e line 1.
Can't find string terminator "'" anywhere before EOF at -e line 1.
Can't find string terminator "'" anywhere before EOF at -e line 1.
Can't find string terminator "'" anywhere before EOF at -e line 1.

What am i doing wrong?

Please help me on this..


Thanks in Advance

PP..

Reply via email to