Perl code request

Hi Perl Experts,

I am new to Perl programming.

can somebody please help me in writing Perl code for following "find and replace logic".

i wanted to find following line in list of files in a given directory.

================================================

for(i=0;i < temp1.temp2;i++) begin

================================================

and replace with following code.

================================================

j = temp1.temp2;

for(i=0;i < j;i++) begin

================================================

Thanks in advance,

Rgds,
Ravi.

I'd use sed, but there is a sed equivalent PERL substitute to change such a line. Do you know how to read a file line by line and write the lines to a second file?

perl -pe 's/for\(i=0\;i < temp1\.temp2\;i\+\+\) begin/j = temp1\.temp2;\nfor\(i=0\;i < j\;i\+\+\) begin/g' file > outfile

if you want to overwrite the file, use -i option, (ex: 'perl -i -pe')