You have 2 options:
1) Use pattern matching which would help in replacement 
s/<pattern to search>/<replacement>

2) Try using split function
$w=split(/<pattern to search. Eg:=>/,$string to search)

3) Try using substr function
Substr($string to search, <number of character from where to start),<end of
character>)


-----Original Message-----
From: Preethi [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 22, 2006 12:37 PM
To: beginners@perl.org
Subject: Urgent :search and replace


Hi Experts,

I have wired problem , I have search and replace string in very huge text
file . The problem with the string is broken in the differenet line.

I'm having a  string 'ab=test1, db=test2,dc=test3' and I want to replace
this with 'ab=chk1,bc=chk2'.
This string in the file is present in various fasion like
<File>
.........................ab=tes
t1, db=test2,dc=test3'....
............................, ab=
test1,db=test2,dc=test3' .
..................................

<EOF>


Now the problem when I use the below command
perl -p -i.bak -e 's/ab=test1, db=test2,dc=test3/ab=chk1,bc=chk2/gi'
filename
works only if they are in the same line. But does not replace if they are on
different lines as the exaple shown above.

Please someone could hlep me give a quick solution for this.





Thanks,
Preethi

Reply via email to