Re: Problem with replacing string in file
- From: rob.dixon@xxxxxxx (Rob Dixon)
- Date: Sat, 25 Nov 2006 16:36:52 +0000
Mumia W. wrote:
[snip]
On 11/25/2006 06:40 AM, perl pra wrote:
Here is the code i have written...
[snip]
open $LOGFILE, '<', $file;
while ($line1 = <$LOGFILE> ) {
if ($line1 =~ m/$key/) {
system("perl -i.bak -p -e 's/$line1/$repline/g' $file");
close $LOGFILE;
last;
}
}
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?
My eyes are too old to see a stray ' somewhere in a program. My guess is
that it has something to do with the call to system (which shouldn't be
called anyway).
It's for two reasons. Firstly $line1 isn't chomped, so there is a newline before
the second slash in the substitution; and secondly Windows doesn't recognise
single quotes as being special on a command line, so Perl is being passed a
parameter list like:
-i.bak
-p
-e
's/PROJ_FOLDER=D:\Proj
/PROJ_FOLDER=D:\Proj/g'
E:/temp/FT/config/FTMessageArchive.configd
and clearly the one-liner has no string terminator!
Rob
.
- References:
- Problem with replacing string in file
- From: Perl Pra
- Re: Problem with replacing string in file
- From: Mumia W.
- Problem with replacing string in file
- Prev by Date: Re: Problem with replacing string in file
- Next by Date: Good Books on Perl, Beginner / Advance
- Previous by thread: Re: Problem with replacing string in file
- Next by thread: Good Books on Perl, Beginner / Advance
- Index(es):
Relevant Pages
|